• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Rapid Blog

  • Enterprise
  • API Hub
  • Add Your API
  • About
  • Docs
    • API Glossary
  • Blog
    • What is an API?
    • REST API Tutorials
    • Most Popular APIs
  • Sign Up
    • Log In
Blog » OpenWeatherMap API Overview » OpenWeatherMap API C#

OpenWeatherMap API C#

OpenWeatherMap C#

You can use the OpenWeatherMap in C# using RestSharp or Unirest.

How to use the OpenWeatherMap API in C# (C# Example)

1. Sign up for a Free RapidAPI User Account

RapidAPI Free API Key

From any page on the RapidAPI Marketplace, click “Sign Up” and register for a free account.

2. Navigate the OpenWeatherMap API page

openweathermap api endpoints console rapidapi

Get to the OpenWeatherMap API Page by clicking here or searching for it in the RapidAPI marketplace search bar.

3. Subscribe to the API

openweathermap api pricing

Next, click on the API’s Pricing Tab and select a plan to subscribe to. The OpenWeatherMap API has 2 pricing plans on RapidAPI:

  1. Basic – OpenWeatherMap’s free plan. $0.00/month with a 100 request/day hard limit. Rate limited at 10 requests/minute.
  2. Pro – $10/month that offers unlimited API requests. Rate limited at 100 requests/minute.

4. Test an OpenWeatherMap API Endpoint

openweathermap API current weather data

After subscribing to a pricing plan, head back to the endpoints page and choose an endpoint, fill out the required parameters, and click “Test Endpoint”.

If done correctly, on the right side of the API console, you should see a response like this:

openweathermap api san francisco weather

5. Copy the C# (RestSharp or Unirest) Code Snippet and add it to your application!

rapidapi code snippets

Now that you have successfully tested that the API works, click on the Code Snippet dropdown and select one of the following:

  • C# –> RestSharp
  • C# –> Unirest

You’ll see something similar to this:

RestSharp

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/weather?q=London%252Cuk");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "[your rapidapi key]");
IRestResponse response = client.Execute(request);
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/weather?q=London%252Cuk"); var request = new RestRequest(Method.GET); request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com"); request.AddHeader("x-rapidapi-key", "[your rapidapi key]"); IRestResponse response = client.Execute(request);
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/weather?q=London%252Cuk");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "[your rapidapi key]");
IRestResponse response = client.Execute(request);

Unirest

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Task<HttpResponse<MyClass>> response = Unirest.get("https://community-open-weather-map.p.rapidapi.com/weather?q=London%252Cuk")
.header("X-RapidAPI-Host", "community-open-weather-map.p.rapidapi.com")
.header("X-RapidAPI-Key", "[your rapidapi key]")
.asJson();
Task<HttpResponse<MyClass>> response = Unirest.get("https://community-open-weather-map.p.rapidapi.com/weather?q=London%252Cuk") .header("X-RapidAPI-Host", "community-open-weather-map.p.rapidapi.com") .header("X-RapidAPI-Key", "[your rapidapi key]") .asJson();
Task<HttpResponse<MyClass>> response = Unirest.get("https://community-open-weather-map.p.rapidapi.com/weather?q=London%252Cuk")
.header("X-RapidAPI-Host", "community-open-weather-map.p.rapidapi.com")
.header("X-RapidAPI-Key", "[your rapidapi key]")
.asJson();

Modify as needed and drop it into your application.

Voila, you’re done!

What data is available with the OpenWeatherMap API?

The OMW API has 4 endpoints available on RapidAPI:

  1. GET Current Weather Data
  2. GET Call 16 day / daily forecast data
  3. GET Search Weather Data
  4. GET 5 day / 3 hour forecast data

GET Current Weather Data

Description: Using this kind of requests you can get weather data in any location on the earth. The current weather data are updated online based on data from more than 40,000 weather stations.

Example request:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/weather?q=London%252Cuk");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "[your rapidapi key]");
IRestResponse response = client.Execute(request);
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/weather?q=London%252Cuk"); var request = new RestRequest(Method.GET); request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com"); request.AddHeader("x-rapidapi-key", "[your rapidapi key]"); IRestResponse response = client.Execute(request);
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/weather?q=London%252Cuk");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "[your rapidapi key]");
IRestResponse response = client.Execute(request);

GET Call 16 day / daily forecast data

Description: 16-day forecasts are available for any location or city. Forecasts include daily weather and available in JSON or XML format. It is only available for all paid accounts.

Example request:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/forecast/daily?q=san%20francisco%252Cus");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "[your rapidapi key]");
IRestResponse response = client.Execute(request);
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/forecast/daily?q=san%20francisco%252Cus"); var request = new RestRequest(Method.GET); request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com"); request.AddHeader("x-rapidapi-key", "[your rapidapi key]"); IRestResponse response = client.Execute(request);
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/forecast/daily?q=san%20francisco%252Cus");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "[your rapidapi key]");
IRestResponse response = client.Execute(request);

GET Search Weather Data

Description: By city name. Input the city name or its part and get the list of the most proper cities in the world. Example – Lon or Lond or London. The more precise city name you put the more precise list you will get. To make it more precise put the city’s name or its part, comma, the name of the county or 2-letter country code. You will get all the proper cities in the chosen county. The order is important – the first is city name then a comma then the county. Example – Lon, UK or Lon, GB or London, GB or Lon, England. By geographic coordinates.

Example request:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/find?units=imperial%252C%20metric&q=london");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "[your rapidapi key]");
IRestResponse response = client.Execute(request);
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/find?units=imperial%252C%20metric&q=london"); var request = new RestRequest(Method.GET); request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com"); request.AddHeader("x-rapidapi-key", "[your rapidapi key]"); IRestResponse response = client.Execute(request);
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/find?units=imperial%252C%20metric&q=london");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "[your rapidapi key]");
IRestResponse response = client.Execute(request);

GET 5 day / 3 hour forecast data

Description: A 5-day forecast is available for any location or city. It includes weather data every 3 hours. The forecast is available in JSON or XML format.

Example request:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/forecast?q=san%20francisco%252Cus");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "[your rapidapi key]");
IRestResponse response = client.Execute(request);
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/forecast?q=san%20francisco%252Cus"); var request = new RestRequest(Method.GET); request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com"); request.AddHeader("x-rapidapi-key", "[your rapidapi key]"); IRestResponse response = client.Execute(request);
var client = new RestClient("https://community-open-weather-map.p.rapidapi.com/forecast?q=san%20francisco%252Cus");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "community-open-weather-map.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "[your rapidapi key]");
IRestResponse response = client.Execute(request);

Related Articles

  • OpenWeatherMap API Python Tutorial
  • Best Free Weather APIs
  • OpenWeatherMap API JavaScript Node.js Tutorial
  • OpenWeatherMap React App
  • Dark Sky vs OpenWeatherMap

Primary Sidebar

Build anything with APIs, faster.

Discover, evaluate, and integrate with any API. RapidAPI is the world’s largest API Hub with over 4 Million developers and 35,000 APIs.

Browse APIs »

Footer

  • API Guides
  • API Courses
  • API Glossary
  • API Testing
  • API Management
  • Most Popular APIs
  • Free APIs List
  • How to use an API
  • Learn REST API
  • Build API’s
  • About
  • Build APIs
  • Careers
  • Contact Us
  • Write for Us
  • API Directory
  • Press Room
  • Privacy Policy
  • Terms of Use

© 2025 RapidAPI. All rights reserved.

Building an Enterprise API Program
Learn More

×