Creating a RESTful JSON API in the AWS API Gateway can be a bit daunting at first. The various resources and methods needed are often what you start with. However, determining what path parameters and querystring parameters are used and how they're integrated into the request can be hard. Learn how to do that.
- [Narrator] The first thing we wanna do in the API gateway is to create our API. Not the final the details for it but just create it and basically give it a name. We can do that from the AWS console. And once we are in the API gateway, we create an API. We'll have some options in there to create a new one, or clone one, possible import or from example that they provide. And then we go to the settings and that's it. It's created for us, and we can be ready to define however we want it to operate. So the steps would be, to go to the console, navigate to API gateway, and then create the API.
Specify the name and the other settings and we're on our way. So back at the AWS console, I'm gonna type 'api' to narrow the search field down to API gateway. And click on that. From here, I'd click 'Get Started'. And it asks us if we wanna create and example API. We don't, but we'll click OK. And we'll be able to select the type we want to create. This example API is pretty interesting. It finds a pet store that allows you to handle different fetches for different pets and information.
I'd recommend that at the end of this course, you might wanna go through that. We can also import an API from swagger. But we're gonna create a completely new API. We'll name our API, 'Music'. We can give it a description, like, 'Fetches music data'. We'll also leave the endpoint at 'Regional'. This is best for testing because we don't need to access this from all over the place. For performance, we can just leave it at one region. And then we create the API.
This is what we'll be looking at when we edit our API. We have a root note with the slash. And over under the name of our API, we have the different areas of our API that we can look at. Resources is where we'll define our different methods, like puts and posts, and our URL note. Stages is where we deploy our API. We'll also spend a lot of time in models. This is where we'll define the format of our data that will be sent to our API, and what our API returns.
If we had other APIs, they'd be listed here. Now when we go to the API gateway, we can see our music API listed. Again, if we had more, there would be a grid of this. We click on music, and we're back to where we can add our resources and methods to the actions. So to create our API, we simply went to the amazon AWS console, navigated to API gateway, and clicked create API. We gave it a name, description, and the other settings.
And we're on our way. For more information on regions and endpoints, you can go to amazon.com and read all about R and E, regions and endpoints.
- Creating APIs with the AWS API Gateway
- Using GET, DELETE, and POST methods and models
- Generating SDKs
- Creating DynamoDB tables
- Creating Lambda functions
- Creating APIs for Lambda
- Generating the client API with Swagger