URL structures mirror that of the main site, but on the
api.openparliament.ca domain. Most pages will have a JSON link in the footer leading to the equivalent API content.
Everything is JSON. But, when you access the page in your browser (or, specifically, with a client whose
Accept header indicates a preference for
application/json), you'll get a friendly formatted page instead. Here, take a look.
It’s hypertext. Most resources link to related resources. Start with bills, votes, MPs, debates, or committees, and you should be able to find your way to what you're looking for. Resources are identified by their URLs, which are of course guaranteed to be unique; if you need a field to use as a primary key for objects, I suggest the URL or a fragment of it. When filtering based on a relationship with another object, you use the URL, like so.
Many resources can be filtered. The list of available filters appears on each resource’s friendly API page. You can use simple operators for most numeric and date fields: gt (greater than), gte (greater than or equal), lt (less than), lte (can you guess?). Here's an example.
There’s a rate limit. If you make tons of concurrent requests, you'll get
HTTP 429 Too Many Requests. Get in touch if this is a problem for you.
Things change. I'm not yet making an ironclad backwards-compatibility promise. If you’re using this, you should sign up for a low-traffic mailing list where I’ll post about any breaking changes. To indicate that you're expecting responses that match the current version of the API, set a
API-Version header to
v1, or include
?version=v1 in your query string. Responses will include an
API-Version header with the version of the response.
Don’t be shy. The API doesn’t currently enforce this, but you should put your email in
User-Agent headers—that way I can look at how people are using the API, and contact you if your requests are causing problems. And please get in touch with comments and questions.