different pieces of software to talk to each other • In Object-Oriented programming, a class’s public methods are its API • APIs can be exposed as web services
allows you to have a single source of truth for your data that you can consume in many different ways. • Website (with either client-side or server-side front-end) • Hybrid mobile app • Native mobile app • Desktop app • Command-line app • Other Services (e.g., Jira, Bamboo, and GitHub APIs can all talk to each other)
(nouns) • Collections or single instances • Can contain other resources (e.g., user has repos) https://www.thoughtworks.com/insights/blog/ rest-api-design-resource-modeling
makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world. • Built-in http package (low-level, roll your own) • Express (de facto standard) • Koa, or thousands of other new contenders (it is JavaScript, remember?) https://www.npmjs.com/search?q=http => 27922 packages found
“Routing refers to determining how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method (GET, POST, and so on).”
made-easier-with-postman/ • Automated tests for your API: https://www.codementor.io/equimper/testing-your- api-with-postman-4tuwpkswp Testing you API: Postman
let port = 7777; app.get('/', function (req, res) { res.send('Welcome to the recipe API.'); }); app.listen(port, function () { console.log(`Recipe API app listening on port ${port}`); });
Object.assign(result, recipe); res.json(result); } else { res.status(404); res.json({ error: 'No recipe with that ID found '}); } } }); res.json(result); } else { res.status(404); res.json({ error: 'No recipe with that ID found '}); } } });
just anybody POST, PUT, and DELETE anything they want in your data • Since REST is stateless, sessions are not an option • API Keys • Username/Password login, with expiring tokens • JSON Web Tokens