To retrieve news data, you will need to use the New York Times API. To access it, you must first register for an account and obtain your API key. Note that the API is only available for non-commercial use and can be accessed for free.
You need to go to the New York Times Developer site (developer.nytimes.com) and create an account to get an API key.
Creating an account for an API key
Once you're at the website, click "Sign in." If you don't already have an account, create one, click Create account, and follow the prompts to register.
Register an app
Once you are registered and signed in, you'll need to register an app to obtain an API key.
To do that, select "Apps" in the user drop-down menu. Once you are on the next page, click "+ New App" to create a new app.
To begin creating your app, start by creating a name for it. Additionally, you have the option to provide a description of what your app is all about.
Once completed, you'll need to apply scopes or permissions for your API Key below.
You can choose from a number of API permissions, but for this project, select the "Top Stories API." With this, you can retrieve articles that are currently featured on the section front or home page.
Once enabled, click the "Save" icon below.
Now that you have your API key, the next step is to use it securely and conveniently. We'll store your API key in an settings.toml file, which is a best practice for keeping sensitive information safe.
Text editor powered by tinymce.