How do I set up google's custom search API?

I have created a new project in my google api dashboard, but when I use the sandbox for the API, it gives me an error. I am really stuck here. When I try to create my custom search engine ID, it expects a domain to search, but I want to search google…

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "conditionNotMet",
    "message": "Need to provide a Custom Search Engine ID. Missing cx or cref parameter.",
    "locationType": "header",
    "location": "If-Match"
   }
  ],
  "code": 412,
  "message": "Need to provide a Custom Search Engine ID. Missing cx or cref parameter."
 }
}

you need to provide these parameterse…

cx: "your custom search id"
key: “custom search api key”

Final request to be made to url is:-

https://www.googleapis.com/customsearch/v1?q={query to be search}&searchType=image&cx={youe-cs-key}&key={your cse api key}

thansk for the reply, i hope this helps someone or me in the future. I went with a different API for the project.

Custom search API can get pretty complex to use. From the code provided it looks like you are missing the cx parameter with is your custom search id. The usage has been illustrated in a previous reply.

You can read more about the parameters here: https://blog.expertrec.com/google-custom-search-json-api-simplified/. It is a simplified version of the API documentation that can help you get started.