Preparations
- Download and install the POSTman app.
- Create a 46elks account.
- Email anna@46elks.com and tell us which workshop you want to participate in.
Why and when use APIs?
- Open up access to data
- Automation - access to systems
- Layer on top of complexity
Be brave!
You’ll encounter terminology and abbreviations that make no sense, and that’s ok!
Terminology
- url
- request
- response
- status codes
- docs
- GET & POST
- Authentication
- format (json, xml, other)
- Open data
Summary
- URL The address. You have a home address.
The API has its home address on the internet. Just like websites.
Example: https://api.46elks.com/a1/SMS - Why & when APIs?
dataportal.se
Trafiklab
20 APIs in 20 minutes - help!?
Contact those providing the API!
Stackoverflow to the rescue!
People! Go to meetups, hackathons, explore forums... when you have friends you can help them out, and they can help you out! - Request
- GET Ask for data.
- POST Send in data. Trigger an event.
- Status codes
- 200 All is well.
- 404 Can't find what you're looking for!
- 20x OK!
- 30x Somewhere else!
-
40x You're not doing it right.
Check the documentation/manual/instruction. Ask for help!
Example: https://46elks.com/thispagedoesnotexist - 404. - 50x We made a mistake! Perhaps you might want to let us know! Or try again later!
- http cat
- Format
- json
[ list, with, values ]
{ key: "value", other_key: "different value"}
- XML
<key>value</key> <other_key>different value</other_key>
- json
- Authentication
- Credentials
- API key
- Basic auth
- Code example in Python
More examples in many different programming languages are available on GitHubimport requests requests.post( "https://api.46elks.com/a1/SMS", auth = (API_USERNAME, API_PASSWORD), data = { "from": "ElkCo", "to": "+46766861004", "message": "It's cold outside, bring a sweater!" } )