- Create a Project in Google Cloud Console:
- Go to the Google Cloud Console.
- Click on the project drop-down and select or create a new project.
- Enable the Custom Search API:
- In the Google Cloud Console, go to the APIs & Services Dashboard.
- Click on "+ ENABLE APIS AND SERVICES".
- Search for "Custom Search API" and enable it.
- Create API Credentials:
- Go to the Credentials page.
- Click on "Create Credentials" and select "API Key".
- Copy the generated API key and keep it safe. This will be your API key for accessing the Google Custom Search API.
- Create a Custom Search Engine:
- Go to the Google Custom Search Engine.
- Click on "New search engine".
- Fill in the required fields:
- In the "Sites to search" field, you can add any website you want to search, or use "example.com" for a basic setup.
- Click "Create".
- Retrieve the Search Engine ID:
- After creating your custom search engine, go to the Custom Search Engine control panel.
- Click on the search engine you just created.
- Under "Details", you will find the "Search engine ID". Copy this ID as you will need it to perform searches using the API.