# Cubes

&#x20;**Getting Started with Cube-Based Queries**

The Ortege API provides multiple ways to query blockchain data depending on your development environment. Whether you’re making **raw HTTP requests** in any language or building applications with **JavaScript/TypeScript** in the frontend, here’s how to access and interact with our data effectively.

#### Choosing Your Query Method

1. **Raw Requests to Endpoints**: Ideal for backend developers or those working in languages other than JavaScript/TypeScript.
2. **Front-End Developers**: Tailored for React or JavaScript/TypeScript environments using Cube’s npm packages and client library.

***

#### Raw Requests: Accessing Data Directly

If you're developing in any language other than JavaScript/TypeScript or need direct HTTP access, you can interact with the Ortege API using raw requests. Here are two popular ways to get started:

**1. Using cURL**

cURL offers a quick, straightforward way to test and integrate with the Ortege API.

* **REST API Request**:

  ```bash
  curl -X POST https://api-staging.ortege.ai/cubejs-api/v1/load \
       -H "Content-Type: application/json" \
       -H "Authorization: Bearer YOUR_JWT_TOKEN" \
       -d '{
             "query": {
               "measures": ["logs.count"],
               "timeDimensions": [{
                 "dimension": "logs.time",
                 "granularity": "hour",
                 "dateRange": "last 1440 minutes"
               }]
             }
           }'
  ```

**2. Using Postman**

Postman allows you to visually interact with the Ortege API and save configurations for future use.&#x20;

1. Import the Ortege [Postman collection](/en/ortege-products/api/postman-collection.md).
2. Set up your `Authorization` header with your JWT token.
3. Customize your requests using Postman’s interface, and save them for quick access to frequently used queries.

***

#### Front-End Developers: Using Cube Client for JavaScript/TypeScript

If you’re building applications with React, JavaScript, or TypeScript, Cube’s npm packages provide a smooth way to integrate with Ortege’s API. Cube offers both a **JavaScript client library** and **React components** that make accessing blockchain data intuitive and efficient.

**1. Setting Up the Cube Client Library**

The Cube client library provides the foundational methods for querying data from our API. Here’s how to get started:

* **Install the Cube client**:

  ```bash
  npm install @cubejs-client/core
  ```
* **Initialize and Query the Client**:

  ```javascript
  import cubejs from '@cubejs-client/core';

  const API_URL = 'https://api-staging.ortege.ai/cubejs-api/v1';
  const cubejsApi = cubejs('YOUR_JWT_TOKEN', { apiUrl: API_URL });

  // Example Query
  cubejsApi.load({
    measures: ['logs.count'],
    timeDimensions: [{
      dimension: 'logs.time',
      granularity: 'hour',
      dateRange: 'last 1440 minutes'
    }]
  }).then(result => {
    console.log(result);
  });
  ```

**2. Integrating with React Components**

Cube’s React components allow you to easily integrate Ortege data into your frontend React application. Follow these steps:

* **Install Cube’s React components**:

  ```bash
  npm install @cubejs-client/react
  ```
* **Using Cube in a React Component**:

  ```javascript
  import React from 'react';
  import { CubeProvider, useCubeQuery } from '@cubejs-client/react';
  import cubejs from '@cubejs-client/core';

  const API_URL = 'https://api-staging.ortege.ai/cubejs-api/v1';
  const cubejsApi = cubejs('YOUR_JWT_TOKEN', { apiUrl: API_URL });

  function DataComponent() {
    const { resultSet, error, isLoading } = useCubeQuery({
      measures: ['logs.count'],
      timeDimensions: [{
        dimension: 'logs.time',
        granularity: 'hour',
        dateRange: 'last 1440 minutes'
      }]
    });

    if (isLoading) return <p>Loading...</p>;
    if (error) return <p>Error: {error.message}</p>;

    return <div>{JSON.stringify(resultSet.rawData())}</div>;
  }

  function App() {
    return (
      <CubeProvider cubejsApi={cubejsApi}>
        <DataComponent />
      </CubeProvider>
    );
  }

  export default App;
  ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ortege.ai/en/ortege-products/api/cubes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
