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
Ein Quicknode-Konto erstellen
Melde dich hier an, falls du das noch nicht getan hast.
Gehen Sie zu Ihrem Dashboard
Öffnen Sie das Endpunkte-Dashboard über das Menü in der linken Seitenleiste, um alle Ihre Blockchain-Endpunkte zu verwalten
Neuen Endpunkt erstellen
Click Create an Endpoint in the top-right corner, select Aptos as your blockchain, then select your preferred network
Kopieren Sie die URLs Ihres Anbieters
Halten Sie die HTTP-URL griffbereit. Sie werden sie in den folgenden Anfragen verwenden.
Eine ausführliche Anleitung zur Nutzung des Quicknode-Dashboards finden Sie in unserem Leitfaden
Senden Sie Ihre erste Anfrage
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. Wählen Sie Ihre bevorzugte Sprache oder Ihr SDK aus und befolgen Sie die nachstehenden Schritte, um Ihre erste Anfrage zu senden.
- cURL
- Node.js
Python
- Ruby
cURL-Installation überprüfen
Die meisten *nix-basierten Systeme unterstützen cURL standardmäßig. Öffnen Sie Ihr Terminal und überprüfen Sie die cURL-Version, indem Sie den folgenden Befehl ausführen:
curl --version
Eine REST-API-Anfrage senden
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'
Beispielantwort
{
"message": "aptos-node:ok"
}
Richten Sie Ihr Projekt ein
Überprüfen Sie zunächst mit dem Befehl „node --version“, ob Node.js installiert ist. Falls nicht, laden Sie es unter https://nodejs.org herunter. Erstellen Sie anschließend ein neues Verzeichnis und initialisieren Sie ein Node.js-Projekt:
mkdir aptos-api-quickstart
cd aptos-api-quickstart
npm init -y
Erstellen Sie Ihre Hauptdatei
Erstellen Sie eine Datei „index.js“ für Ihren Code:
touch index.js
Füge diesen Code in deine Datei „index.js“ ein
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();
Führen Sie Ihren Code aus
Speichern Sie die Datei und führen Sie sie in Ihrem Terminal aus:
node index.js
Python-Installation überprüfen
Überprüfen Sie, ob Python auf Ihrem System installiert ist. Öffnen Sie Ihr Terminal und führen Sie folgenden Befehl aus:
python --version
Erforderliche Pakete installieren
Installieren Sie die „requests“-Bibliothek, falls Sie dies noch nicht getan haben:
pip install Requests
Erstellen Sie Ihr Python-Skript
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)
Führen Sie Ihr Skript aus
Save the file as aptos_health.py and run it:
python aptos_health.py
Ruby-Installation überprüfen
Überprüfen Sie, ob Ruby auf Ihrem System installiert ist. Öffnen Sie Ihr Terminal und führen Sie folgenden Befehl aus:
ruby --version
Erstellen Sie Ihr Ruby-Skript
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
Führen Sie Ihr Skript aus
Save the file as aptos_health.rb and run it:
ruby aptos_health.rb
Wenn Sie mehr über das Absenden von API-Anfragen erfahren möchten, sehen Sie sich unsere Anleitungen und Beispiel-Apps an.
Wir ❤️ Feedback!
Wenn Sie Anregungen oder Fragen zu dieser Dokumentation haben, teilen Sie uns diese bitte mit. Wir freuen uns auf Ihre Rückmeldung!