The quickest way to start building on Bitcoin with Quicknode is by sending a JSON-RPC request to your endpoint. In this quickstart, 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 Bitcoin Endpoint
Quicknode 계정 만들기
아직 가입하지 않으셨다면 여기에서 가입해 주세요.
대시보드로 이동하세요
왼쪽 사이드바 메뉴에서 ‘엔드포인트’ 대시보드를 열어 모든 블록체인 엔드포인트를 관리하세요
새 엔드포인트 생성
Click Create an Endpoint in the top-right corner, select Bitcoin as your blockchain, then select your preferred network
서비스 제공업체 URL을 복사하세요
HTTP URL을 잘 챙겨 두세요. 아래에서 요청을 보낼 때 이 URL을 사용하게 될 것입니다.
Quicknode 대시보드에 대한 자세한 사용 방법은 당사의 가이드를 확인해 주세요
첫 요청 보내기
Your endpoint is ready. Now, let's make your first call to the Bitcoin blockchain. We'll use the getblock method, which retrieves detailed information about a specific block by its hash. 원하는 언어 또는 SDK를 선택한 후, 아래 단계를 따라 첫 번째 요청을 보내보세요..
- cURL
파이썬
- 자바스크립트
- 루비
cURL 설치 상태 확인
대부분의 *nix 기반 시스템은 기본적으로 cURL을 지원합니다. 터미널을 열고 아래 명령어를 실행하여 cURL 버전을 확인하세요:
curl --version
JSON-RPC 요청 보내기
In your terminal, copy and paste the following cURL command to retrieve block information:
curl YOUR_QUICKNODE_ENDPOINT_URL/ \
-X POST \
-H "Content-Type: application/json" \
--data '{"id": 1, "jsonrpc": "2.0", "method": "getblock", "params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]}'
답변 예시
{
"result": {
"hash": "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
"confirmations": 912736,
"size": 216,
"height": 1000,
"version": 1,
"versionHex": "00000001",
"merkleroot": "fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33",
"tx": [
"fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33"
],
"time": 1232346882,
"mediantime": 1232344831,
"nonce": 2595206198,
"bits": "1d00ffff",
"difficulty": 1,
"chainwork": "000000000000000000000000000000000000000000000000000003e903e903e9",
"nTx": 1,
"previousblockhash": "0000000008e647742775a230787d66fdf92c46a48c896bfbc85cdc8acc67e87d",
"nextblockhash": "00000000a2887344f8db859e372e7e4bc26b23b9de340f725afbf2edb265b4c6"
},
"error": null,
"id": 1
}
프로젝트 설정하기
Python 프로젝트를 위한 새 디렉터리를 생성하세요:
mkdir bitcoin-python-quickstart
cd bitcoin-python-quickstart
가상 환경 생성 및 활성화
의존성을 관리하기 위한 가상 환경을 생성합니다:
python3 -m venv venv
source venv/bin/activate
설치 요청
HTTP 요청을 보내기 위해 requests 라이브러리를 설치하세요:
pip 설치 requests
파이썬 스크립트(app.py)를 만듭니다.
다음 코드가 포함된 Python 파일을 만드세요:
import requests
import json
# Your Quicknode endpoint URL
url = "YOUR_QUICKNODE_ENDPOINT_URL/"
# JSON-RPC request payload for getblock
payload = json.dumps({
"id": 1,
"jsonrpc": "2.0",
"method": "getblock",
"params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]
})
headers = {
'Content-Type': 'application/json'
}
# Make the request
response = requests.request("POST", url, headers=headers, data=payload)
result = response.json()
print("Block information:")
print(json.dumps(result, indent=2))
스크립트를 실행하세요
파이썬 스크립트를 실행하세요:
python app.py
프로젝트 설정하기
새 디렉터리를 만들고 Node.js 프로젝트를 초기화합니다:
mkdir bitcoin-js-quickstart
cd bitcoin-js-quickstart
npm init -y
자바스크립트 파일(app.js)을 만듭니다.
Create an app.js file with the following code (using native https module):
const https = require('https');
// Your Quicknode endpoint URL
const data = JSON.stringify({
"id": 1,
"jsonrpc": "2.0",
"method": "getblock",
"params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]
});
const options = {
hostname: '{your-endpoint-name}.quiknode.pro',
path: '/{your-token}/',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
const req = https.request(options, (res) => {
let result = '';
res.on('data', (chunk) => {
result += chunk;
});
res.on('end', () => {
console.log('Block information:');
console.log(JSON.parse(result));
});
});
req.on('error', (error) => {
console.error('Error:', error);
});
req.write(data);
req.end();
스크립트를 실행하세요
자바스크립트 스크립트를 실행하세요:
node app.js
프로젝트 설정하기
Ruby 프로젝트를 위한 새 디렉터리를 생성하세요:
mkdir bitcoin-ruby-quickstart
cd bitcoin-ruby-quickstart
Ruby 설치 상태 확인
시스템에 Ruby가 설치되어 있는지 확인하십시오. 설치되어 있지 않다면, https://ruby-lang.org에서 설치하십시오:
ruby --version
Ruby 스크립트(main.rb)를 만듭니다.
다음 코드가 포함된 main.rb 파일을 생성하세요:
require "uri"
require "json"
require "net/http"
# Your Quicknode endpoint URL
url = URI("YOUR_QUICKNODE_ENDPOINT_URL/")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"id": 1,
"jsonrpc": "2.0",
"method": "getblock",
"params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]
})
response = https.request(request)
result = JSON.parse(response.read_body)
puts "Block information:"
puts JSON.pretty_generate(result)
스크립트를 실행하세요
Execute your Ruby script to retrieve block information:
ruby main.rb
API 요청 방법에 대해 더 자세히 알아보고 싶으시다면, 당사의 가이드와 샘플 앱을 확인해 보세요.
여러분의 피드백을 ❤️ 환영합니다!
이 문서에 대한 의견이나 질문이 있으시면 언제든지 알려주세요. 여러분의 의견을 기다리고 있습니다!