Get Weather Forecast
curl --request POST \
--url https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"city": "London",
"country": "United States",
"lat": 51.5074,
"lon": -0.1278,
"state": "California",
"zip": "10001"
}
'import requests
url = "https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast"
payload = {
"city": "London",
"country": "United States",
"lat": 51.5074,
"lon": -0.1278,
"state": "California",
"zip": "10001"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
city: 'London',
country: 'United States',
lat: 51.5074,
lon: -0.1278,
state: 'California',
zip: '10001'
})
};
fetch('https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'city' => 'London',
'country' => 'United States',
'lat' => 51.5074,
'lon' => -0.1278,
'state' => 'California',
'zip' => '10001'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast"
payload := strings.NewReader("{\n \"city\": \"London\",\n \"country\": \"United States\",\n \"lat\": 51.5074,\n \"lon\": -0.1278,\n \"state\": \"California\",\n \"zip\": \"10001\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"city\": \"London\",\n \"country\": \"United States\",\n \"lat\": 51.5074,\n \"lon\": -0.1278,\n \"state\": \"California\",\n \"zip\": \"10001\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"city\": \"London\",\n \"country\": \"United States\",\n \"lat\": 51.5074,\n \"lon\": -0.1278,\n \"state\": \"California\",\n \"zip\": \"10001\"\n}"
response = http.request(request)
puts response.read_body{
"details": [
{
"feels_like": 123,
"humidity": 123,
"max_temp": 123,
"min_temp": 123,
"sunrise": 123,
"sunset": 123,
"temp": 123,
"wind_degrees": 123,
"wind_speed": 123
}
]
}API Ninjas
Get Weather Forecast
Get Weather Forecast
POST
https://api.aisa.one
/
apis
/
v1
/
api-ninjas
/
get-weather-forecast
Get Weather Forecast
curl --request POST \
--url https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"city": "London",
"country": "United States",
"lat": 51.5074,
"lon": -0.1278,
"state": "California",
"zip": "10001"
}
'import requests
url = "https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast"
payload = {
"city": "London",
"country": "United States",
"lat": 51.5074,
"lon": -0.1278,
"state": "California",
"zip": "10001"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
city: 'London',
country: 'United States',
lat: 51.5074,
lon: -0.1278,
state: 'California',
zip: '10001'
})
};
fetch('https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'city' => 'London',
'country' => 'United States',
'lat' => 51.5074,
'lon' => -0.1278,
'state' => 'California',
'zip' => '10001'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast"
payload := strings.NewReader("{\n \"city\": \"London\",\n \"country\": \"United States\",\n \"lat\": 51.5074,\n \"lon\": -0.1278,\n \"state\": \"California\",\n \"zip\": \"10001\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"city\": \"London\",\n \"country\": \"United States\",\n \"lat\": 51.5074,\n \"lon\": -0.1278,\n \"state\": \"California\",\n \"zip\": \"10001\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"city\": \"London\",\n \"country\": \"United States\",\n \"lat\": 51.5074,\n \"lon\": -0.1278,\n \"state\": \"California\",\n \"zip\": \"10001\"\n}"
response = http.request(request)
puts response.read_body{
"details": [
{
"feels_like": 123,
"humidity": 123,
"max_temp": 123,
"min_temp": 123,
"sunrise": 123,
"sunset": 123,
"temp": 123,
"wind_degrees": 123,
"wind_speed": 123
}
]
}请求规范
- 方法与路径: POST /apis/v1/api-ninjas/get-weather-forecast
- 可用状态: enabled
- 请求 URL 模板:
https://api.aisa.one/apis/v1/api-ninjas/get-weather-forecast
{
"operationId": "api-ninjas.get-weather-forecast",
"method": "POST",
"path": "/apis/v1/api-ninjas/get-weather-forecast",
"servers": [
{
"url": "https://api.aisa.one"
}
],
"parameters": [],
"security": [
{
"bearerAuth": []
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"city": {
"description": "City name (premium feature). Alternative to lat/lon.",
"examples": [
"London",
"New York"
],
"type": "string"
},
"country": {
"description": "Country name or ISO code (premium feature). Use with city parameter.",
"examples": [
"United States",
"US"
],
"type": "string"
},
"lat": {
"description": "Latitude coordinate (-90 to 90). Must be used together with lon parameter.",
"examples": [
51.5074,
40.7128
],
"maximum": 90,
"minimum": -90,
"type": "number"
},
"lon": {
"description": "Longitude coordinate (-180 to 180). Must be used together with lat parameter.",
"examples": [
-0.1278,
-74.006
],
"maximum": 180,
"minimum": -180,
"type": "number"
},
"state": {
"description": "US state name or abbreviation (for United States cities only, premium feature). Use with city parameter.",
"examples": [
"California",
"CA"
],
"type": "string"
},
"zip": {
"description": "5-digit ZIP code for United States locations only (premium feature). Alternative to lat/lon.",
"examples": [
"10001",
"90210"
],
"type": "string"
}
},
"type": "object"
}
}
},
"required": false
},
"x-aisa-status": "enabled",
"components": {
"securitySchemes": {
"bearerAuth": {
"scheme": "bearer",
"type": "http"
}
}
}
}
费用与请求规则
按实际用量收费。 默认请求预估费用:$0.00089 USD。 最终费用以实际用量为准。 账户适用价格可能不同;支持报价的接口可按实际请求获取报价。授权
请求体
application/json