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
Criar uma conta no Quicknode
Inscreve-te aqui, se ainda não o fizeste.
Aceda ao seu painel de controlo
Abra o painel «Endpoints» a partir do menu da barra lateral esquerda para gerir todos os seus endpoints de blockchain
Criar um novo ponto de extremidade
Click Create an Endpoint in the top-right corner, select Aptos as your blockchain, then select your preferred network
Copie os URLs do seu fornecedor
Tenha a URL HTTP à mão. Vai precisar dela nas solicitações que vai fazer a seguir.
Para um guia detalhado do painel do Quicknode, consulte o nosso guia
Envie o seu primeiro pedido
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. Selecione o seu idioma ou SDK preferido e siga os passos abaixo para enviar o seu primeiro pedido.
- cURL
- Node.js
Python
- Ruby
Verificar a instalação do cURL
A maioria dos sistemas baseados em *nix já inclui suporte ao cURL de fábrica. Abra o terminal e verifique a versão do cURL executando o comando abaixo:
curl --versão
Send a REST API request
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'
Exemplo de resposta
{
"message": "aptos-node:ok"
}
Configure o seu projeto
Primeiro, verifique se o Node.js está instalado com o comando `node --version`. Se não estiver instalado, descarregue-o em https://nodejs.org. Em seguida, crie um novo diretório e inicialize um projeto Node.js:
mkdir aptos-api-quickstart
cd aptos-api-quickstart
npm init -y
Crie o seu ficheiro principal
Crie um ficheiro index.js para o seu código:
touch index.js
Adicione este código ao seu ficheiro 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();
Run your code
Save the file and run it in your terminal:
node index.js
Check Python installation
Verify Python is installed on your system. Open your terminal and run:
python --version
Install required packages
Install the requests library if you haven't already:
pip instalar requests
Create your Python script
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)
Run your script
Save the file as aptos_health.py and run it:
python aptos_health.py
Verificar a instalação do Ruby
Verify Ruby is installed on your system. Open your terminal and run:
ruby --versão
Create your Ruby script
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
Run your script
Save the file as aptos_health.rb and run it:
ruby aptos_health.rb
Se quiseres continuar a aprender sobre como efetuar pedidos à API, consulta os nossos guias e aplicações de exemplo.
Adoramos ❤️ os vossos comentários!
Se tiver algum comentário ou dúvida sobre esta documentação, não hesite em contactar-nos. Adoraríamos saber a sua opinião!