ubahnverleih / WoBike

Documentation of Bike Sharing APIs 🚴🛴🛵
948 stars 131 forks source link

Response 200 issue for bird api #54

Open PJPJPJPJPJ opened 5 years ago

PJPJPJPJPJ commented 5 years ago

Below is the python code I used. I get a response 200 error. Could somebody tell me where could have gone wrong? Thanks!

import requests
import json

headers = {"Device-id": "123E4567-E89B-12D3-A456-426655440060", "Platform": "ios", "Content-Type": "application/json"}
login = {"email": "birdapi1240@gmail.com"}
response = requests.post('https://api.bird.co/user/login', json=login, headers=headers)
login = json.loads(response.text)

token = login["token"]

headers2 = {"Authorization": 'Bird' + ' ' + token,
            "Device-id": "123E4567-E89B-12D3-A456-426655440060",
            "App-Version": "3.0.5",
            "Location": json.dumps({"latitude":33.781105,"longitude":-84.3863329})}

results = requests.get("https://api.bird.co/bird/nearby?latitude=33.781105&longitude=-84.3863329&radius=100", headers = headers2)

Out[27]: <Response [200]>

dschep commented 5 years ago

200 is the HTTP code for OK, not an error. To get the data out of the response object, you'll want results.json()

PJPJPJPJPJ commented 5 years ago

200 is the HTTP code for OK, not an error. To get the data out of the response object, you'll want results.json()

Thank you, dschep! I also have a question about this result. Does it show the location of the scooters at the time when I send out the request? Or does it show the location at some time in the past?