# API queries

Run **DataPrime** or **Lucene** queries directly from your code—no need to open the Coralogix UI.

Choose the API architecture that best fits your workflow:

- **JSON over HTTP**
- **gRPC**

For large or recurring analytics jobs (like monthly or quarterly reports), use **background queries** that run asynchronously. These are available via both [JSON-over-HTTP](https://coralogix.com/docs/dataprime/API/direct-archive-query-http/index.md) and [gRPC](https://coralogix.com/docs/dataprime/API/direct-archive-query-grpc/index.md).

## Quick comparison

| Feature                | JSON over HTTP                              | gRPC              |
| ---------------------- | ------------------------------------------- | ----------------- |
| **Transport Security** | HTTPS                                       | HTTPS             |
| **Request Format**     | JSON (POST body)                            | Protobuf message  |
| **Response Format**    | NDJSON for streaming JSON for non-streaming | Protobuf stream   |
| **Status Codes**       | Standard HTTP                               | gRPC status codes |

## Setup & authentication

All requests must be sent over HTTPS, regardless of whether you're using HTTP or gRPC.

To get started:

1. Choose the https://api.\[[DOMAIN_VALUE]\]/api/v1/dataprime/query endpoint that corresponds to your Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain/index.md) using the domain selector at the top of the page.
1. Create a personal or team [API key](https://coralogix.com/docs/user-guides/account-management/api-keys/api-keys/index.md).
1. Include your API key in the Authorization header of your request:

```bash
Authorization: Bearer <YOUR_API_KEY>
```

Note

Select the DataQuerying permission preset to keep your key automatically aligned with future permission updates.

## Required permissions

| Action                           | Purpose                             |
| -------------------------------- | ----------------------------------- |
| `LEGACY-ARCHIVE-QUERIES:EXECUTE` | Query archived data                 |
| `LOGS.DATA-API#HIGH:READDATA`    | Query frequent‑search logs          |
| `LOGS.DATA-API#LOW:READDATA`     | Query monitoring & compliance logs  |
| `METRICS.DATA-API#HIGH:READDATA` | Query metrics                       |
| `SPANS.DATA-API#HIGH:READDATA`   | Query frequent‑search spans         |
| `SPANS.DATA-API#LOW:READDATA`    | Query monitoring & compliance spans |

## Next steps

Choose your guide and jump straight into examples:

- [JSON over HTTP reference](https://coralogix.com/docs/dataprime/API/direct-archive-query-http/index.md) – request/response schema, examples, and error handling.
- [gRPC reference](https://coralogix.com/docs/dataprime/API/direct-archive-query-grpc/index.md) – proto definitions and streaming examples.

## Additional resources

|                     |                                                                                             |
| ------------------- | ------------------------------------------------------------------------------------------- |
| Coralogix Endpoints | [Coralogix Endpoints](https://coralogix.com/docs/integrations/coralogix-endpoints/index.md) |
