GithubHelp home page GithubHelp logo

java-openweathermap-api's Introduction

Java OpenWeatherMap API

Release

A light OpenWeatherMap API for Java.

Setup

  1. Either build the JAR or download it from the latest release

  2. Create a folder, "lib", in the directory of a new/existing project

  3. Move or copy the JAR file into the lib folder

  4. Add the JAR file to the build path

    IDEA: From the Project window, select and right-click the lib folder, then click Add as Library...

    Eclipse: From the Package Explorer, select and right-click the JAR file, then select Build and click Add to Build Path

Usage

  1. In a Java source file, import the OpenWeatherMap API
import owmapi.OwmApi;
  1. Create an instance of the API
OwmApi owmApi = new OwmApi();
  1. Set the OpenWeatherMap App ID by passing it as a string
owmApi.setAppId("OWM-App-ID-Here");
  1. Get weather report based on zipcode
String weatherReport = owmApi.runWithZipcode("75080-3021");

A Complete Example

import owmapi.OwmApi;

public class Main {

    public static void main(String[] args) {
        run("OWM-App-ID-Here", "75080-3021");
    }

    public static void run(String appId, String zipcode) {
        OwmApi owmApi = new OwmApi();
        owmApi.setAppId(appId);
        String weatherReport = owmApi.runWithZipcode(zipcode);
        if (weatherReport != null) {
            System.out.println(weatherReport);
        }
    }

}

Result:

Weather forecast for Richardson city: cloudy and a temperature of 80.9 with a high of 84.2 and a low of 77.0

API Reference

setAppId(String)

    Sets the OpenWeatherMap App ID for retrieving data from the web API

runWithZip(String)

    Runs the Java OpenWeatherMap API using zip code information

Note: This API includes more methods; however, this covers the majority of its functionality at this time.

Contributing

All pull requests are welcome.

java-openweathermap-api's People

Contributors

ronrihoo avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.