APIs Flashcards

1
Q

What is RESTful routing?

A

REST is a naming and routing convention used by APIs that mostly return JSON. REST dictates the url route for each HTTP method that may be used to make a request to the API. An example for an API that returns a fact about an animal might be to use a -“GET” - request to the route api/animals/:id. If the API allowed you to then delete the animal from the database, there could be a -“DELETE” - request to the same route.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a resource?

A

In terms of RESTful routing, the resource is how we identify the object (typically table name) we are mapping to. The “/resource” comes after the domain name, when we have nested routes we have multiple resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When building a JSON API why do you not include routes to render a form that when submitted creates a new user?

A

A JSON API is intended to simply return JSON data to the client based on the request sent to the server. This API doesn’t generally bother with how a user may actually send the request, so it wouldn’t need to include a route that renders a form. Instead, this can be done on the front end, and the data gathered from the form can be sent as JSON to the JSON API where it will be processed accordingly, and JSON will be returned in response.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between authorization and authentication?

A
  • Authentication is the process of determining whether or not a user is actually a valid user. This can help keep bots away from your application, but is mostly used to make sure the person attempting to access your application is actually registered / signed-up before they can access anything.
    • Authorization is the level of access the authenticated user has within the application. For example, a user may be an admin, meaning they are authorized to see details about other user accounts while a regular user would only be able to see details about their own.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly