The quickest way to start building on Aptos with Quicknode is by sending a REST API request to your endpoint. In this guide, you'll create an endpoint, copy its provider URL, and make your first request. Code samples are available in cURL as well as popular SDKs and programming languages.
Get Your Aptos Endpoint
Crear una cuenta en Quicknode
Regístrate aquí si aún no lo has hecho.
Ve a tu panel de control
Abre el panel de control de Endpoints desde el menú de la barra lateral izquierda para gestionar todos tus puntos de conexión de la cadena de bloques
Crear un nuevo punto final
Click Create an Endpoint in the top-right corner, select Aptos as your blockchain, then select your preferred network
Copia las URL de tus proveedores
Ten a mano la URL HTTP. La vas a utilizar en las solicitudes que vas a realizar a continuación.
Si quieres ver una explicación detallada del panel de control de Quicknode, echa un vistazo a nuestra guía
Envía tu primera solicitud
Your endpoint is ready. Now, let's make your first call to the Aptos blockchain. We'll use the v1 method, which returns information about the Aptos node. Selecciona tu idioma o SDK preferido y sigue los pasos que se indican a continuación para enviar tu primera solicitud.
- cURL
- Node.js
Python
- Rubí
Comprobar la instalación de cURL
La mayoría de los sistemas basados en *nix son compatibles con cURL de serie. Abre el terminal y comprueba la versión de cURL ejecutando el siguiente comando:
curl --versión
Enviar una solicitud a la API REST
In your terminal, copy and paste the following cURL command to check if the Aptos node is healthy:
curl -X 'GET' 'YOUR_QUICKNODE_ENDPOINT_URL/v1/-/healthy' \
-H 'Content-Type: application/json'
Ejemplo de respuesta
{
"message": "aptos-node:ok"
}
Configura tu proyecto
En primer lugar, comprueba que Node.js esté instalado ejecutando el comando `node --version`. Si no está instalado, descárgalo desde https://nodejs.org. A continuación, crea un nuevo directorio e inicializa un proyecto de Node.js:
mkdir aptos-api-quickstart
cd aptos-api-quickstart
npm init -y
Crea tu archivo principal
Crea un archivo «index.js» para tu código:
touch index.js
Añade este código a tu archivo index.js
Copy and paste this code into your index.js file to check if the Aptos node is healthy:
const https = require('https');
const options = {
hostname: '{your-endpoint-name}.quiknode.pro',
path: '/{your-token}/v1/-/healthy',
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
};
const req = https.request(options, (res) => {
let result = '';
res.on('data', (chunk) => {
result += chunk;
});
res.on('end', () => {
console.log(result);
});
});
req.on('error', (error) => {
console.error('Error:', error);
});
req.end();
Ejecuta tu código
Guarda el archivo y ejecútalo en tu terminal:
nodo index.js
Comprobar la instalación de Python
Comprueba que Python esté instalado en tu sistema. Abre el terminal y ejecuta:
python --versión
Instalar los paquetes necesarios
Instala la biblioteca «requests» si aún no lo has hecho:
pip instalar requests
Crea tu script en Python
Create a new Python file and add the following code to check if the Aptos node is healthy:
import requests
url = "YOUR_QUICKNODE_ENDPOINT_URL/v1/-/healthy"
headers = {
'Content-Type': 'application/json'
}
response = requests.request("GET", url, headers=headers)
print(response.text)
Ejecuta tu script
Save the file as aptos_health.py and run it:
python aptos_health.py
Comprobar la instalación de Ruby
Comprueba que Ruby esté instalado en tu sistema. Abre el terminal y ejecuta:
ruby --versión
Crea tu script en Ruby
Create a new Ruby file and add the following code to check if the Aptos node is healthy:
require 'net/http'
require 'json'
uri = URI('YOUR_QUICKNODE_ENDPOINT_URL/v1/-/healthy')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['Content-Type'] = 'application/json'
response = http.request(request)
puts response.body
Ejecuta tu script
Save the file as aptos_health.rb and run it:
ruby aptos_health.rb
Si quieres seguir aprendiendo a realizar solicitudes a la API, echa un vistazo a nuestras guías y aplicaciones de ejemplo.
¡Nos encanta recibir comentarios!
Si tienes algún comentario o pregunta sobre esta documentación, háznoslo saber. ¡Nos encantaría saber tu opinión!