Ad
Acces All Data From RDW API By Adding App Token
For a school project i need to work with the information that a api is giving me. I choose for the RDW API(Dutch License plate info). What i now have is only acces to 1000 licenseplates but i want to be able to get all off them.
import urllib.request
import json
url = "https://opendata.rdw.nl/resource/m9d7-ebf2.json?"
json_data_request = urllib.request.urlopen(url)
json_data = json.loads(json_data_request.readall().decode("utf-8"))
print(len(json_data))
With this code i'm only able to acces 1000 licenceplates What i want to get to work is(kenteken=licenceplate):
def locu_search(kenteken):
api_key = "CYcaHHuuvFfG2apjnvns8Ob41"
url = "https://opendata.rdw.nl/resource/m9d7-ebf2.json?$$app_token=" + api_key
after_url = "kenteken=" + kenteken
final_url = url + after_url
json_data_request = urllib.request.urlopen(final_url)
json_data = json.loads(json_data_request.readall().decode("utf-8"))
#print all info with that licenceplate
kenteken = input("Licenceplate:")
locu_search(kenteken)
What this code should do is:
- ask for licenceplate.
- go to the function with the value you put in.
- print all information of that licenceplate.(not here yet because i can't get the previous lines not to work)
I searched but was not able to get this working any info i can work with?
Ad
Answer
There are a couple of things you'll need to change in your code:
- You'll need to add an ampersand (
&
) betweenurl
andafter_url
to separate those two parameters:final_url = url + "&" + after_url
- If you want to retrieve more than 1000 records per request, you'll need to use the
$limit
and$offset
paging parameters: https://dev.socrata.com/docs/paging.html
Ad
source: stackoverflow.com
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad