Understanding request and response headers in the NewsCatcher APIs
This guide explains the HTTP headers used in the NewsCatcher APIs, including
required request headers, useful response headers, and best practices for
working with them.
The x-process-time header shows how long it took our system to process your
request (in seconds):
Copy
Ask AI
x-process-time: 0.7334954738616943
This can be useful for performance monitoring and optimization. If you
consistently see high process times, consider optimizing your queries or
implementing caching strategies.
Here are the examples of how to work with headers in your requests for differnt
programming languages:
Copy
Ask AI
curl -X POST "https://v3-api.newscatcherapi.com/api/search" \ -H "x-api-token: YOUR_API_KEY_HERE" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"q": "bitcoin", "from_": "30d"}' \ -i# The -i flag displays response headers in the output# Look for the correlation-id in the response headers
Always use the correct authentication header: Use x-api-token instead
of x-api-key for authentication.
Always log correlation IDs: Store correlation IDs alongside your
application logs for easier troubleshooting.
Monitor process times: Keep track of x-process-time values to identify
performance trends or issues.
Handle headers consistently: Implement consistent header handling in your
error handling and logging code.
Be aware of case sensitivity: While HTTP headers are case-insensitive in
the protocol, many libraries preserve the original casing when accessing
them.
Add proper Content-Type headers: Always include the
Content-Type: application/json header for POST requests.