Comments (5)
Looks like the API response from creating a station contains the ID, so when you POST
to create a station the response is
{
"ID": "583436dd9643a9000196b8d6",
"updated_at": "2016-11-22T12:15:25.96727176Z",
"created_at": "2016-11-22T12:15:25.967271732Z",
"user_id": "557066d0ff7a7e3897531d94",
"external_id": "SF_TEST001",
"name": "San Francisco Test Station",
"latitude": 37.76,
"longitude": -122.43,
"altitude": 150,
"source_type": 5
}
To delete this station you would DELETE /stations/583436dd9643a9000196b8d6
.
I see that you're doing it in Python. If you can't make it work, try doing it with this ruby client, and post the code that fails here and we'll try to help.
from open-weather-ruby-client.
No, not simple as DELETE /stations/583436dd9643a9000196b8d6...
For exemple :
[GET] /stations/{:id}
This method is used to get information about one station with a standard set of attributes: external and internal identifiers, creation and update timestamps, name, geographical arrangement, height above sea level and station rank.
URL Example : http://api.openweathermap.org/data/3.0/stations/583436dd9643a9000196b8d6
My Python version 1 :
def openweather_station_get_info (id) :
URL_GETINFO = 'http://api.openweathermap.org/data/3.0/stations/' + id
headers = {'Content-Type' : 'application/json'}
print (URL_GETINFO)
reponse = requests.get(url=URL_GETINFO, headers=headers, timeout=TIMEOUT)
return (reponse.text)
REPONSE -> {"cod":401, "message": "Invalid API key. Please see https://openweathermap.org/faq#error401 for more info."}
My Python version 2 :
def openweather_station_get_info (id) :
URL_GETINFO = 'http://api.openweathermap.org/data/3.0/stations?appid=' + APIKEY_OPEN_WEATHER + "&" + id
headers = {'Content-Type' : 'application/json'}
print (URL_GETINFO)
reponse = requests.get(url=URL_GETINFO, headers=headers, timeout=TIMEOUT)
return (reponse.text)
REPONSE -> [{"id":"658a868b8885c200018ae8f0","created_at":"2023-12-26T07:53:47.091Z","updated_at":"2023-12-26T07:53:47.091Z","external_id":"MI_12100","name":"Meteo Millau Les Aumieres","longitude":3.077801,"latitude":44.100575,"altitude":501,"rank":10},{"id":"658bdad78885c200018ae8f4","created_at":"2023-12-27T08:05:43.354Z","updated_at":"2023-12-27T08:05:43.354Z","external_id":"MILLAU","name":"Meteo MILLAU","longitude":3,"latitude":40,"altitude":500,"rank":10},{"id":"658bdb458885c200018ae8f5","created_at":"2023-12-27T08:07:33.729Z","updated_at":"2023-12-27T08:07:33.729Z","external_id":"MILLAU","name":"Meteo MILLAU","longitude":3,"latitude":40,"altitude":500,"rank":10},{"id":"658bdb578885c200018ae8f6","created_at":"2023-12-27T08:07:51.642Z","updated_at":"2023-12-27T08:07:51.642Z","external_id":"MILLAU","name":"Meteo MILLAU","longitude":3,"latitude":40,"altitude":500,"rank":10}]
List ALL the stations but not the one asked with id...
My question, is always the same : in [GET] /stations/{:id} (or [PUT] /stations/{:id} or[DELETE] /stations/{:id}), how should I put the {:id] parameter ?
Thanks...
from open-weather-ruby-client.
My question, is always the same : in [GET] /stations/{:id} (or [PUT] /stations/{:id} or[DELETE] /stations/{:id}), how should I put the {:id] parameter ?
By including it in the URL. Here's what I did in curl.
export OPENWEATHER_API_KEY=...
List of stations.
curl -H "Content-type: application/json" "https://api.openweathermap.org/data/3.0/stations?appid=$OPENWEATHER_API_KEY"
[]
Create a station.
curl -X POST -H "Content-type: application/json" "https://api.openweathermap.org/data/3.0/stations?appid=$OPENWEATHER_API_KEY" --data '{"external_id": "SF_TEST001", "name": "San Francisco Test Station","latitude": 37.76,"longitude": -122.43,"altitude": 150}'
{"ID":"658f0ab78885c200018ae902","updated_at":"2023-12-29T18:06:47.443257147Z","created_at":"2023-12-29T18:06:47.44325694Z","user_id":"5ea78db637e5c60007120f2c","external_id":"SF_TEST001","name":"San Francisco Test Station","latitude":37.76,"longitude":-122.43,"altitude":150,"rank":10,"source_type":5}
Get a station by ID.
curl -X GET -H "Content-type: application/json" "https://api.openweathermap.org/data/3.0/stations/658f0ab78885c200018ae902?appid=$OPENWEATHER_API_KEY"
{"id":"658f0ab78885c200018ae902","created_at":"2023-12-29T18:06:47.443Z","updated_at":"2023-12-29T18:06:47.443Z","external_id":"SF_TEST001","name":"San Francisco Test Station","longitude":-122.43,"latitude":37.76,"altitude":150,"rank":10}
Delete the station.
curl -X DELETE -H "Content-type: application/json" "https://api.openweathermap.org/data/3.0/stations/658f0ab78885c200018ae902?appid=$OPENWEATHER_API_KEY"
Does this help?
from open-weather-ruby-client.
### Yes thank you, it's perfect!
I was stuck on this seemingly very simple question for several days! :-((
Thanks to you, I finally understood the structure to use with [GET], [PUT] or [DELETE].
You will admit that the documentation which simply indicates "[GET] /stations/{:id}" is not very explicit! :-(
Last little question, do you know the meaning and usefulness of the parameter field named "{rank}" systematically returned during a [GET] query? I haven't seen any mention of it in their documentation...?
Thank you very much for your valuable help Daniel!
from open-weather-ruby-client.
I was stuck on this seemingly very simple question for several days! :-((
No stress! These things are only simple in hindsight. Glad it worked out.
Last little question, do you know the meaning and usefulness of the parameter field named "{rank}" systematically returned during a [GET] query? I haven't seen any mention of it in their documentation...?
No idea!
from open-weather-ruby-client.
Related Issues (17)
- Add support for hourly forecast
- Add support for OneCall API
- Add support for 16 day/daily forecast
- Add support for 30 day forecast
- Add support for 5 day forecast
- Add support for historical data HOT 1
- Add support for maps APIs
- Add support for weather stations HOT 2
- Cache Faraday::Connection and use Faraday::Adapter::NetHttpPersistent HOT 1
- Specialize 429 errors
- Change endpoint to not include version HOT 2
- Create a command-line client
- OpenSSL::SSL::SSLError on Heroku HOT 3
- Missing 'summary' in OpenWeather::Models::OneCall::DailyWeather HOT 3
- Support location names in other than ISO 3166 HOT 8
- One Call API 2.5 to be closed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from open-weather-ruby-client.