# Harem Gold API Documentation > Integration documentation for the Pixcharp Harem Gold API: authentication, REST endpoints, WebSocket stream, IP whitelist, error codes and plans. Source: https://docs.pixcharp.com/en · Last updated: 2026-11-27 Use one secure REST API, or a WebSocket stream, to bring current Harem Altın prices into your e-commerce site, mobile app, internal tool, or notification workflow. ## Quick start Pick a plan on Pixcharp or start the 7-day free trial, open your customer dashboard, and generate an API key. Keep the raw key on your server and send it with every request. ```bash curl https://api.pixcharp.com/v1/prices \ -H "X-API-Key: $PIXCHARP_API_KEY" ``` On JavaScript or TypeScript, the open-source `harem-altin-api` client handles REST and WebSocket for you. npm: https://www.npmjs.com/package/harem-altin-api · GitHub: https://github.com/Baristopal/harem-altin-api ```javascript // npm install harem-altin-api import { createClient } from "harem-altin-api"; const client = createClient({ apiKey: process.env.PIXCHARP_API_KEY }); const has = await client.getPrice("HAS"); console.log(has.symbol, has.alis, has.satis); ``` ## Topics Each step of the integration has its own page. - [Authentication and IP whitelist](https://docs.pixcharp.com/en/authentication) ([Markdown](https://docs.pixcharp.com/en/authentication.md)): Every REST request and WebSocket connection is authenticated with an API key. This page shows how to send the key and how the IP whitelist limits it to your own servers. - [REST endpoints and JSON responses](https://docs.pixcharp.com/en/rest-api) ([Markdown](https://docs.pixcharp.com/en/rest-api.md)): Current gold and currency prices come as JSON from four GET endpoints. Pick one and get a real response from the try-it console. - [Live gold prices over WebSocket](https://docs.pixcharp.com/en/websocket) ([Markdown](https://docs.pixcharp.com/en/websocket.md)): Get prices as they change instead of polling. On connect the stream sends every price, then only the ones that changed, at most once a second. - [Error codes and limits](https://docs.pixcharp.com/en/errors-and-limits) ([Markdown](https://docs.pixcharp.com/en/errors-and-limits.md)): Errors come back with an HTTP status and a machine-readable error code. Limits depend on your plan, and what you have left is in the response headers. - [Code examples](https://docs.pixcharp.com/en/code-examples) ([Markdown](https://docs.pixcharp.com/en/code-examples.md)): The same request in twelve languages, ready to copy and run. On JavaScript or TypeScript, the open-source client covers REST and WebSocket in one package. ## Plans | Plan | Monthly requests | Per-minute limit | WebSocket connections | Allowed IPs | Monthly / yearly | | --- | --- | --- | --- | --- | --- | | Trial | 10,000 | 30 | 1 | 1 | Free · 7 days | | Starter | 200,000 | 60 | - | 1 | $12.99 / $129.90 · ₺650 / ₺6,500 | | Pro | 1,000,000 | 180 | 2 | 4 | $24.99 / $249.90 · ₺1,250 / ₺12,500 | | Business | 5,000,000 | 600 | 10 | 10 | $59.99 / $599.90 · ₺3,000 / ₺30,000 | Prices include VAT. Yearly billing costs the same as 10 months. WebSocket messages count toward monthly requests too. The trial needs no card and is available once per email address. ## FAQ ### What is the Harem Gold API? A data service from Pixcharp that delivers live buy and sell prices for has gold, gram gold, çeyrek, 22 karat, ounce gold and TRY exchange rates as JSON, over a REST API and a WebSocket stream. ### Is it Harem Altın's official API? No. It is an independent service run by Pixcharp, with no official connection or partnership with Harem Altın. Pixcharp handles sales, invoicing and support. ### How do I get an API key, and is there a free trial? Start the 7-day free trial on the product page (no card needed) or pick a plan, then create a key starting with `pxa_live_` in the customer dashboard. The trial includes 10,000 requests, 30 requests per minute and 1 WebSocket connection. ### How often are prices updated? REST endpoints return the latest price on every call. The WebSocket stream sends at most one message a second while prices change. Every row carries an `asOfUtc` time and a `stale` flag that shows when data is older than expected. ### Which symbols are available? Has gold (`HAS`), gram gold (`GRAM_ALTIN`), çeyrek (`CEYREK_YENI`), exchange rates such as `USDTRY`, and more. Call `GET /v1/symbols` for the full list on your account. ### Which programming languages can I use? Any language that speaks HTTP and WebSocket. This page has samples in cURL, JavaScript, Python, PHP, Go, Java, C#, Ruby, Rust, Kotlin, Swift and Dart, and there is an open-source `harem-altin-api` client for JavaScript and TypeScript. ### Can I call it directly from a mobile app or a browser? Do not put the key in an app bundle or browser code. Call the API from your own server and pass prices on to your app. If you need WebSocket from a browser, use a dedicated key and an IP whitelist. ### What happens when I hit a limit? Going over the per-minute limit returns `429 rate_limit_exceeded`; a full monthly quota returns `429 monthly_quota_exceeded`. What you have left is in the `X-RateLimit-Remaining` and `X-Quota-Remaining` headers. ## Links - Documentation home: https://docs.pixcharp.com/en - Product page and plans: https://pixcharp.com/en/harem-gold-api - Customer dashboard: https://panel.pixcharp.com/en/api/login - JavaScript/TypeScript client (open source): https://github.com/Baristopal/harem-altin-api - Türkçe sürüm: https://docs.pixcharp.com/index.md - Contact: hello@pixcharp.com --- # Authentication and IP whitelist > Authenticate Harem Gold API calls with the X-API-Key header or a Bearer token, keep keys safe, and lock them to your server addresses with the IP whitelist. Source: https://docs.pixcharp.com/en/authentication · Last updated: 2026-11-27 Every REST request and WebSocket connection is authenticated with an API key. This page shows how to send the key and how the IP whitelist limits it to your own servers. ## Authentication Use either `X-API-Key` or a Bearer token. Do not expose your key in browser bundles, mobile binaries, screenshots, or logs. - Header: `X-API-Key: pxa_live_...` - Bearer: `Authorization: Bearer pxa_live_...` - Format: `pxa_live_...` ## IP whitelist Add your server addresses in the customer dashboard. While the list is empty, every address is accepted. Once it has entries, REST and WebSocket calls from any other address get `403 ip_not_allowed`, and those calls do not use your quota. Single IPv4 and IPv6 addresses and CIDR ranges are accepted; Starter allows 1 entry, Pro 4 and Business 10. ```json { "title": "ip_not_allowed", "status": 403, "detail": "Requests from 198.51.100.9 are not allowed for this API client. Add the address to the allowed IP list." } ``` The detail shows the address the API saw, which is the one to add when you are unsure of your server's outbound IP. ## Links - Documentation home: https://docs.pixcharp.com/en - Product page and plans: https://pixcharp.com/en/harem-gold-api - Customer dashboard: https://panel.pixcharp.com/en/api/login - JavaScript/TypeScript client (open source): https://github.com/Baristopal/harem-altin-api - Türkçe sürüm: https://docs.pixcharp.com/kimlik-dogrulama.md - Contact: hello@pixcharp.com --- # REST endpoints and JSON responses > Harem Gold API REST endpoints: /v1/prices, /v1/prices/{symbol}, /v1/symbols and /v1/status, with a live try-it console and the JSON response shape for gold prices. Source: https://docs.pixcharp.com/en/rest-api · Last updated: 2026-11-27 Current gold and currency prices come as JSON from four GET endpoints. Pick one and get a real response from the try-it console. ## Endpoints The first version is intentionally focused on current prices, symbol discovery, and feed health. Base URL: `https://api.pixcharp.com` | Method | Path | Description | | --- | --- | --- | | GET | `/v1/prices` | Return all current prices in one response. | | GET | `/v1/prices/{symbol}` | Return the price of one symbol. | | GET | `/v1/symbols` | List the symbols available to your account. | | GET | `/v1/status` | Check feed freshness and status. | ### cURL ```bash curl https://api.pixcharp.com/v1/prices/HAS \ -H "X-API-Key: $PIXCHARP_API_KEY" ``` The same request in JavaScript, Python, PHP and nine more languages: https://docs.pixcharp.com/en/code-examples ``` GET https://api.pixcharp.com/health/live GET https://api.pixcharp.com/health/ready ``` ## Responses `alis` is the buy price and `satis` the sell price. `stale: true` means the data is older than expected. ```json { "version": "v1", "asOfUtc": "2026-08-05T10:24:13Z", "source": "harem", "stale": false, "data": [ { "symbol": "HAS", "alis": 6127.46, "satis": 6155.99, "kapanis": null, "acilis": null, "asOfUtc": "2026-08-05T10:24:13Z", "source": "harem", "stale": false } ] } ``` ## Links - Documentation home: https://docs.pixcharp.com/en - Product page and plans: https://pixcharp.com/en/harem-gold-api - Customer dashboard: https://panel.pixcharp.com/en/api/login - JavaScript/TypeScript client (open source): https://github.com/Baristopal/harem-altin-api - Türkçe sürüm: https://docs.pixcharp.com/rest-api.md - Contact: hello@pixcharp.com --- # Live gold prices over WebSocket > Stream live gold and currency prices over wss://api.pixcharp.com/v1/stream: connecting, snapshot and prices messages, symbol subscriptions, quota and WebSocket error codes. Source: https://docs.pixcharp.com/en/websocket · Last updated: 2026-11-27 Get prices as they change instead of polling. On connect the stream sends every price, then only the ones that changed, at most once a second. ## Connecting and quota Pro and Business plans can open a plain WebSocket to `wss://api.pixcharp.com/v1/stream`. Authenticate with the same API key as REST. You get all prices in one `snapshot` message on connect. After that, as prices change, you get at most one `prices` message a second with the latest value of every symbol that changed in that second. Each `snapshot` and `prices` message uses 1 request of your monthly quota; `ping`, `pong`, `error` and `subscribed` are free, and seconds with no change cost nothing. REST calls and all open connections share the quota. The connection handshake also counts toward the per-minute limit. ### Node.js ```javascript // Install: npm install ws import WebSocket from "ws"; const ws = new WebSocket("wss://api.pixcharp.com/v1/stream", { headers: { "X-API-Key": process.env.PIXCHARP_API_KEY }, }); ws.on("open", () => { // Optional: only the symbols you need. [] or ["*"] restores all. ws.send(JSON.stringify({ type: "subscribe", symbols: ["HAS", "USDTRY"] })); }); ws.on("message", (raw) => { const message = JSON.parse(raw.toString()); if (message.type === "snapshot") console.log(message.data.length, "symbols"); if (message.type === "prices") for (const row of message.data) console.log(row.symbol, row.satis); }); ``` ### Python ```python # Install: pip install "websockets>=14" import asyncio import json import os import websockets async def main(): async with websockets.connect( "wss://api.pixcharp.com/v1/stream", additional_headers={"X-API-Key": os.environ["PIXCHARP_API_KEY"]}, ) as ws: # Optional: only the symbols you need. [] or ["*"] restores all. await ws.send(json.dumps({"type": "subscribe", "symbols": ["HAS", "USDTRY"]})) async for raw in ws: message = json.loads(raw) if message["type"] == "prices": for row in message["data"]: print(row["symbol"], row["satis"]) asyncio.run(main()) ``` ### Go ```go // Install: go get github.com/gorilla/websocket package main import ( "fmt" "net/http" "os" "github.com/gorilla/websocket" ) func main() { header := http.Header{"X-API-Key": {os.Getenv("PIXCHARP_API_KEY")}} conn, _, err := websocket.DefaultDialer.Dial("wss://api.pixcharp.com/v1/stream", header) if err != nil { panic(err) } defer conn.Close() // Optional: only the symbols you need. [] or ["*"] restores all. conn.WriteJSON(map[string]any{"type": "subscribe", "symbols": []string{"HAS", "USDTRY"}}) for { var message struct { Type string `json:"type"` Data []map[string]any `json:"data"` } if err := conn.ReadJSON(&message); err != nil { panic(err) } if message.Type == "prices" { for _, row := range message.Data { fmt.Println(row["symbol"], row["satis"]) } } } } ``` ### C# ```csharp // .NET 7+ using System.Net.WebSockets; using System.Text; using System.Text.Json; using var ws = new ClientWebSocket(); ws.Options.SetRequestHeader("X-API-Key", Environment.GetEnvironmentVariable("PIXCHARP_API_KEY")); await ws.ConnectAsync(new Uri("wss://api.pixcharp.com/v1/stream"), CancellationToken.None); // Optional: only the symbols you need. [] or ["*"] restores all. var subscribe = Encoding.UTF8.GetBytes("""{"type":"subscribe","symbols":["HAS","USDTRY"]}"""); await ws.SendAsync(subscribe, WebSocketMessageType.Text, true, CancellationToken.None); var buffer = new byte[64 * 1024]; while (ws.State == WebSocketState.Open) { using var message = new MemoryStream(); WebSocketReceiveResult result; do { result = await ws.ReceiveAsync(buffer, CancellationToken.None); message.Write(buffer, 0, result.Count); } while (!result.EndOfMessage); using var json = JsonDocument.Parse(message.ToArray()); if (json.RootElement.GetProperty("type").GetString() == "prices") foreach (var row in json.RootElement.GetProperty("data").EnumerateArray()) Console.WriteLine($"{row.GetProperty("symbol")} {row.GetProperty("satis")}"); } ``` ### Browser ```javascript // Browsers cannot set WebSocket headers, so the key goes in the URL. // Use a dedicated key and an IP whitelist; prefer the header from servers. const ws = new WebSocket("wss://api.pixcharp.com/v1/stream?apiKey=" + encodeURIComponent(key)); ws.onmessage = (event) => { const message = JSON.parse(event.data); if (message.type === "prices") for (const row of message.data) console.log(row.symbol, row.satis); }; ``` ## Messages ```text // On connect, and again after "subscribe" {"type":"snapshot","asOfUtc":"2026-11-14T10:24:13Z","market":"open","data":[{"symbol":"HAS","alis":6127.46,"satis":6155.99,...}]} // As prices change, at most once a second (1 request of quota) {"type":"prices","asOfUtc":"2026-11-14T10:24:14Z","data":[{"symbol":"USDTRY","alis":41.1,"satis":41.2,"asOfUtc":"2026-11-14T10:24:14Z","source":"harem","stale":false}]} // Every 30 seconds (no reply needed) {"type":"ping","ts":"2026-11-14T10:24:43Z"} // A bad client message; the connection stays open {"type":"error","code":"invalid_symbol","message":"..."} ``` ## Connection errors | HTTP | Code | Meaning | | --- | --- | --- | | 400 | `websocket_required` | The request was not a WebSocket upgrade. | | 403 | `websocket_not_included` | Your plan has no WebSocket connections (Starter). | | 403 | `ip_not_allowed` | The address is not on your IP whitelist. | | 429 | `websocket_connection_limit` | All connections of your plan are open. Connections from all keys count together. | | 429 | `monthly_quota_exceeded` | Your monthly quota is used up. New connections are refused until it resets on the 1st (UTC). | ## Connection checks and reconnecting Open connections are re-checked every 60 seconds. If the key is revoked, the plan changes, the address leaves the whitelist or the monthly quota runs out, the server sends an `error` message and closes with code 1008. While the market keeps moving, one always-open connection lasts about 11 days on Pro and the whole month on Business. Reconnect with backoff after any close. ## Links - Documentation home: https://docs.pixcharp.com/en - Product page and plans: https://pixcharp.com/en/harem-gold-api - Customer dashboard: https://panel.pixcharp.com/en/api/login - JavaScript/TypeScript client (open source): https://github.com/Baristopal/harem-altin-api - Türkçe sürüm: https://docs.pixcharp.com/websocket.md - Contact: hello@pixcharp.com --- # Error codes and limits > Harem Gold API error codes (401, 403, 404, 429, 503), per-minute rate limits, monthly quota and the X-RateLimit-Remaining and X-Quota-Remaining response headers. Source: https://docs.pixcharp.com/en/errors-and-limits · Last updated: 2026-11-27 Errors come back with an HTTP status and a machine-readable error code. Limits depend on your plan, and what you have left is in the response headers. ## Error codes Successful and throttled responses expose the API version, rate limit, and monthly quota state when available. | HTTP | Code | Meaning | | --- | --- | --- | | 401 | `api_key_required / invalid_api_key` | Authentication is missing or invalid. | | 403 | `revoked_api_key / inactive_client / ip_not_allowed` | The key or account is disabled, or the address is not whitelisted. | | 404 | `unknown_symbol` | The symbol is not available. | | 429 | `rate_limit_exceeded / monthly_quota_exceeded` | Slow down or upgrade the plan. | | 503 | `price_feed_empty` | The upstream price data is not ready. | Response headers: `X-API-Version`, `X-RateLimit-Remaining`, `X-Quota-Remaining` ## Limits by plan REST calls and WebSocket messages share one monthly quota, which resets on the 1st (UTC). | Plan | Monthly requests | Per-minute limit | WebSocket connections | Allowed IPs | | --- | --- | --- | --- | --- | | Trial | 10,000 | 30 | 1 | 1 | | Starter | 200,000 | 60 | - | 1 | | Pro | 1,000,000 | 180 | 2 | 4 | | Business | 5,000,000 | 600 | 10 | 10 | ## Links - Documentation home: https://docs.pixcharp.com/en - Product page and plans: https://pixcharp.com/en/harem-gold-api - Customer dashboard: https://panel.pixcharp.com/en/api/login - JavaScript/TypeScript client (open source): https://github.com/Baristopal/harem-altin-api - Türkçe sürüm: https://docs.pixcharp.com/hata-kodlari.md - Contact: hello@pixcharp.com --- # Code examples > Request samples for the Harem Gold API in cURL, JavaScript, Python, PHP, Go, Java, C#, Ruby, Rust, Kotlin, Swift and Dart, plus the open-source harem-altin-api client. Source: https://docs.pixcharp.com/en/code-examples · Last updated: 2026-11-27 The same request in twelve languages, ready to copy and run. On JavaScript or TypeScript, the open-source client covers REST and WebSocket in one package. ## JavaScript / TypeScript client On JavaScript or TypeScript, the open-source `harem-altin-api` client handles REST and WebSocket for you. npm: https://www.npmjs.com/package/harem-altin-api · GitHub: https://github.com/Baristopal/harem-altin-api ```javascript // npm install harem-altin-api import { createClient } from "harem-altin-api"; const client = createClient({ apiKey: process.env.PIXCHARP_API_KEY }); const has = await client.getPrice("HAS"); console.log(has.symbol, has.alis, has.satis); ``` ## REST request samples A `GET /v1/prices/HAS` call for one symbol's price, in twelve languages. Keep the key in the `PIXCHARP_API_KEY` environment variable instead of in your code. ### cURL ```bash curl https://api.pixcharp.com/v1/prices/HAS \ -H "X-API-Key: $PIXCHARP_API_KEY" ``` ### JavaScript ```javascript // Node.js 18+, Deno, Bun const response = await fetch("https://api.pixcharp.com/v1/prices/HAS", { headers: { "X-API-Key": process.env.PIXCHARP_API_KEY }, }); if (!response.ok) throw new Error(`HTTP ${response.status}`); const price = await response.json(); console.log(price.symbol, price.alis, price.satis); ``` ### Python ```python # Install: pip install requests import os import requests response = requests.get( "https://api.pixcharp.com/v1/prices/HAS", headers={"X-API-Key": os.environ["PIXCHARP_API_KEY"]}, timeout=10, ) response.raise_for_status() price = response.json() print(price["symbol"], price["alis"], price["satis"]) ``` ### PHP ```php true, CURLOPT_HTTPHEADER => ["X-API-Key: " . getenv("PIXCHARP_API_KEY")], CURLOPT_TIMEOUT => 10, ]); $price = json_decode(curl_exec($client), true); curl_close($client); echo $price["symbol"], " ", $price["alis"], " ", $price["satis"], PHP_EOL; ``` ### Go ```go package main import ( "encoding/json" "fmt" "net/http" "os" ) type Price struct { Symbol string `json:"symbol"` Alis float64 `json:"alis"` Satis float64 `json:"satis"` AsOfUtc string `json:"asOfUtc"` Stale bool `json:"stale"` } func main() { req, _ := http.NewRequest(http.MethodGet, "https://api.pixcharp.com/v1/prices/HAS", nil) req.Header.Set("X-API-Key", os.Getenv("PIXCHARP_API_KEY")) res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() var price Price if err := json.NewDecoder(res.Body).Decode(&price); err != nil { panic(err) } fmt.Println(price.Symbol, price.Alis, price.Satis) } ``` ### Java ```java // Java 11+ import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class Main { public static void main(String[] args) throws Exception { HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.pixcharp.com/v1/prices/HAS")) .header("X-API-Key", System.getenv("PIXCHARP_API_KEY")) .GET() .build(); HttpResponse response = HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` ### C# ```csharp // .NET 6+ using System.Net.Http.Json; using var http = new HttpClient { BaseAddress = new Uri("https://api.pixcharp.com") }; http.DefaultRequestHeaders.Add("X-API-Key", Environment.GetEnvironmentVariable("PIXCHARP_API_KEY")); var price = await http.GetFromJsonAsync("/v1/prices/HAS"); Console.WriteLine($"{price!.Symbol} {price.Alis} {price.Satis}"); record Price(string Symbol, decimal Alis, decimal Satis, DateTime AsOfUtc, bool Stale); ``` ### Ruby ```ruby require "net/http" require "json" uri = URI("https://api.pixcharp.com/v1/prices/HAS") request = Net::HTTP::Get.new(uri) request["X-API-Key"] = ENV.fetch("PIXCHARP_API_KEY") response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) } price = JSON.parse(response.body) puts "#{price["symbol"]} #{price["alis"]} #{price["satis"]}" ``` ### Rust ```rust // Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, serde_json = "1", // tokio = { version = "1", features = ["full"] } #[tokio::main] async fn main() -> Result<(), Box> { let price: serde_json::Value = reqwest::Client::new() .get("https://api.pixcharp.com/v1/prices/HAS") .header("X-API-Key", std::env::var("PIXCHARP_API_KEY")?) .send() .await? .error_for_status()? .json() .await?; println!("{} {} {}", price["symbol"], price["alis"], price["satis"]); Ok(()) } ``` ### Kotlin ```kotlin // Do not ship the key inside an app bundle; make this call from your own server. import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse fun main() { val request = HttpRequest.newBuilder(URI("https://api.pixcharp.com/v1/prices/HAS")) .header("X-API-Key", System.getenv("PIXCHARP_API_KEY")) .build() val response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()) println(response.body()) } ``` ### Swift ```swift // Do not ship the key inside an app bundle; make this call from your own server. import Foundation struct Price: Decodable { let symbol: String let alis: Double let satis: Double } var request = URLRequest(url: URL(string: "https://api.pixcharp.com/v1/prices/HAS")!) request.setValue(ProcessInfo.processInfo.environment["PIXCHARP_API_KEY"], forHTTPHeaderField: "X-API-Key") let (data, _) = try await URLSession.shared.data(for: request) let price = try JSONDecoder().decode(Price.self, from: data) print(price.symbol, price.alis, price.satis) ``` ### Dart ```dart // Do not ship the key inside an app bundle; make this call from your own server. // Install: dart pub add http import 'dart:convert'; import 'dart:io'; import 'package:http/http.dart' as http; Future main() async { final response = await http.get( Uri.parse('https://api.pixcharp.com/v1/prices/HAS'), headers: {'X-API-Key': Platform.environment['PIXCHARP_API_KEY']!}, ); final price = jsonDecode(response.body) as Map; print('${price['symbol']} ${price['alis']} ${price['satis']}'); } ``` WebSocket samples in the same languages are on the WebSocket stream page: https://docs.pixcharp.com/en/websocket ## Links - Documentation home: https://docs.pixcharp.com/en - Product page and plans: https://pixcharp.com/en/harem-gold-api - Customer dashboard: https://panel.pixcharp.com/en/api/login - JavaScript/TypeScript client (open source): https://github.com/Baristopal/harem-altin-api - Türkçe sürüm: https://docs.pixcharp.com/kod-ornekleri.md - Contact: hello@pixcharp.com --- # Harem Altın API Dokümantasyonu > Pixcharp Harem Altın API entegrasyon dokümantasyonu: kimlik doğrulama, REST uç noktaları, WebSocket akışı, IP whitelist, hata kodları ve planlar. Kaynak: https://docs.pixcharp.com · Son güncelleme: 2026-11-27 Güncel Harem Altın fiyatlarını tek bir güvenli REST API ya da WebSocket akışıyla e-ticaret sitenize, mobil uygulamanıza, iç araçlarınıza veya bildirim akışlarınıza taşıyın. ## Hızlı başlangıç Pixcharp'tan bir plan seçin ya da 7 günlük ücretsiz denemeyi başlatın, müşteri panelini açın ve bir API anahtarı oluşturun. Ham anahtarı sunucunuzda tutun ve her istekle birlikte gönderin. ```bash curl https://api.pixcharp.com/v1/prices \ -H "X-API-Key: $PIXCHARP_API_KEY" ``` JavaScript veya TypeScript kullanıyorsanız açık kaynak `harem-altin-api` istemcisi REST ve WebSocket'i sizin yerinize yönetir. npm: https://www.npmjs.com/package/harem-altin-api · GitHub: https://github.com/Baristopal/harem-altin-api ```javascript // npm install harem-altin-api import { createClient } from "harem-altin-api"; const client = createClient({ apiKey: process.env.PIXCHARP_API_KEY }); const has = await client.getPrice("HAS"); console.log(has.symbol, has.alis, has.satis); ``` ## Konular Entegrasyonun her adımı kendi sayfasında anlatılır. - [Kimlik doğrulama ve IP whitelist](https://docs.pixcharp.com/kimlik-dogrulama) ([Markdown](https://docs.pixcharp.com/kimlik-dogrulama.md)): Her REST isteği ve WebSocket bağlantısı bir API anahtarıyla doğrulanır. Bu sayfa anahtarın nasıl gönderileceğini ve IP whitelist ile yalnızca kendi sunucularınızdan nasıl kullanılacağını anlatır. - [REST uç noktaları ve JSON yanıtlar](https://docs.pixcharp.com/rest-api) ([Markdown](https://docs.pixcharp.com/rest-api.md)): Güncel altın ve döviz fiyatları dört GET uç noktasından JSON olarak gelir. Bir uç nokta seçip deneme konsolundan gerçek bir yanıt alabilirsiniz. - [WebSocket ile canlı altın fiyatı akışı](https://docs.pixcharp.com/websocket) ([Markdown](https://docs.pixcharp.com/websocket.md)): Fiyatları sürekli sorgulamak yerine değiştikçe alın. Akış bağlanınca tüm fiyatları, sonra yalnızca değişenleri en fazla saniyede bir gönderir. - [Hata kodları ve limitler](https://docs.pixcharp.com/hata-kodlari) ([Markdown](https://docs.pixcharp.com/hata-kodlari.md)): Hatalar bir HTTP durum kodu ve makine tarafından okunabilir bir hata koduyla döner. Limitler plana göre değişir; kalan hakkınız yanıt başlıklarında görünür. - [Kod örnekleri](https://docs.pixcharp.com/kod-ornekleri) ([Markdown](https://docs.pixcharp.com/kod-ornekleri.md)): Aynı isteği on iki dilde gösteren, kopyalayıp çalıştırabileceğiniz örnekler. JavaScript veya TypeScript kullanıyorsanız açık kaynak istemci REST ve WebSocket'i tek pakette sunar. ## Planlar | Plan | Aylık istek | Dakika başı limit | WebSocket bağlantısı | İzinli IP | Aylık / yıllık | | --- | --- | --- | --- | --- | --- | | Deneme | 10.000 | 30 | 1 | 1 | Ücretsiz · 7 gün | | Starter | 200.000 | 60 | - | 1 | 650 TL / 6.500 TL · $12,99 / $129,90 | | Pro | 1.000.000 | 180 | 2 | 4 | 1.250 TL / 12.500 TL · $24,99 / $249,90 | | Business | 5.000.000 | 600 | 10 | 10 | 3.000 TL / 30.000 TL · $59,99 / $599,90 | Fiyatlara KDV dahildir. Yıllık ödeme 10 aylık ücrete denk gelir. WebSocket mesajları da aylık istekten düşer. Deneme kart bilgisi gerektirmez ve her e-posta adresi için bir kez açılır. ## Sık sorulan sorular ### Harem Altın API nedir? Pixcharp'ın sunduğu, has altın, gram altın, çeyrek, 22 ayar, ons ve döviz kurlarının canlı alış-satış fiyatlarını REST API ve WebSocket akışıyla JSON olarak veren bir veri servisidir. ### Harem Altın'ın resmi API'si mi? Hayır. Pixcharp tarafından işletilen bağımsız bir hizmettir; Harem Altın ile resmi bir bağı veya ortaklığı yoktur. Satış, faturalama ve destek Pixcharp tarafından yapılır. ### API anahtarı nasıl alınır, ücretsiz deneme var mı? Ürün sayfasından kart gerektirmeyen 7 günlük ücretsiz denemeyi başlatın ya da bir plan seçin, ardından müşteri panelinden `pxa_live_` ile başlayan bir anahtar oluşturun. Deneme 10.000 istek, dakikada 30 istek ve 1 WebSocket bağlantısı içerir. ### Fiyatlar ne sıklıkla güncellenir? REST uç noktaları her çağrıda en güncel fiyatı döndürür. WebSocket akışı fiyat değiştiğinde en fazla saniyede bir mesaj gönderir. Her kayıtta `asOfUtc` zamanı ve verinin beklenenden eski olduğunu gösteren `stale` alanı bulunur. ### Hangi semboller var? Has altın (`HAS`), gram altın (`GRAM_ALTIN`), çeyrek (`CEYREK_YENI`), döviz kurları (`USDTRY` gibi) ve daha fazlası. Hesabınızdaki tam liste için `GET /v1/symbols` çağırın. ### Hangi programlama dilleriyle kullanılır? HTTP ve WebSocket kullanabilen her dille. Bu sayfada cURL, JavaScript, Python, PHP, Go, Java, C#, Ruby, Rust, Kotlin, Swift ve Dart örnekleri var. JavaScript ve TypeScript için açık kaynak `harem-altin-api` istemcisi de mevcut. ### Mobil uygulamada veya tarayıcıda doğrudan kullanabilir miyim? Anahtarı uygulama paketine veya tarayıcı koduna koymayın. İstekleri kendi sunucunuzdan yapıp fiyatları uygulamanıza oradan iletin. Tarayıcıdan WebSocket gerekiyorsa ayrı bir anahtar ve IP whitelist kullanın. ### Limit aşılırsa ne olur? Dakika limiti aşılınca `429 rate_limit_exceeded`, aylık kota dolunca `429 monthly_quota_exceeded` döner. Kalan hakkınız `X-RateLimit-Remaining` ve `X-Quota-Remaining` başlıklarında görünür. ## Bağlantılar - Dokümantasyon ana sayfası: https://docs.pixcharp.com - Ürün sayfası ve planlar: https://pixcharp.com/tr/harem-altin-api - Müşteri paneli: https://panel.pixcharp.com/tr/api/giris - JavaScript/TypeScript istemcisi (açık kaynak): https://github.com/Baristopal/harem-altin-api - English version: https://docs.pixcharp.com/en.md - İletişim: hello@pixcharp.com --- # Kimlik doğrulama ve IP whitelist > Harem Altın API'de X-API-Key başlığı veya Bearer token ile kimlik doğrulama, anahtar güvenliği ve anahtarı sunucu IP'lerinize kilitleyen IP whitelist. Kaynak: https://docs.pixcharp.com/kimlik-dogrulama · Son güncelleme: 2026-11-27 Her REST isteği ve WebSocket bağlantısı bir API anahtarıyla doğrulanır. Bu sayfa anahtarın nasıl gönderileceğini ve IP whitelist ile yalnızca kendi sunucularınızdan nasıl kullanılacağını anlatır. ## Kimlik doğrulama `X-API-Key` başlığını ya da Bearer token'ı kullanın. Anahtarınızı tarayıcı kodunda, mobil uygulama paketlerinde, ekran görüntülerinde veya loglarda açığa çıkarmayın. - Başlık: `X-API-Key: pxa_live_...` - Bearer: `Authorization: Bearer pxa_live_...` - Biçim: `pxa_live_...` ## IP whitelist Sunucu adreslerinizi müşteri panelinden ekleyin. Liste boşken her adres kabul edilir. Listeye kayıt eklediğinizde başka adreslerden gelen REST ve WebSocket çağrıları `403 ip_not_allowed` alır ve bu çağrılar kotanızdan düşmez. Tekil IPv4 ve IPv6 adresleri ile CIDR aralıkları kabul edilir; Starter 1, Pro 4, Business 10 kayda izin verir. ```json { "title": "ip_not_allowed", "status": 403, "detail": "Requests from 198.51.100.9 are not allowed for this API client. Add the address to the allowed IP list." } ``` Hata ayrıntısında API'nin gördüğü adres yer alır. Sunucunuzun çıkış IP'sinden emin değilseniz eklemeniz gereken adres budur. ## Bağlantılar - Dokümantasyon ana sayfası: https://docs.pixcharp.com - Ürün sayfası ve planlar: https://pixcharp.com/tr/harem-altin-api - Müşteri paneli: https://panel.pixcharp.com/tr/api/giris - JavaScript/TypeScript istemcisi (açık kaynak): https://github.com/Baristopal/harem-altin-api - English version: https://docs.pixcharp.com/en/authentication.md - İletişim: hello@pixcharp.com --- # REST uç noktaları ve JSON yanıtlar > Harem Altın API REST uç noktaları: /v1/prices, /v1/prices/{symbol}, /v1/symbols ve /v1/status. Canlı deneme konsolu ve altın fiyatı JSON yanıt yapısı. Kaynak: https://docs.pixcharp.com/rest-api · Son güncelleme: 2026-11-27 Güncel altın ve döviz fiyatları dört GET uç noktasından JSON olarak gelir. Bir uç nokta seçip deneme konsolundan gerçek bir yanıt alabilirsiniz. ## Uç noktalar İlk sürüm bilerek güncel fiyatlara, sembol listesine ve veri akışının sağlığına odaklanır. Base URL: `https://api.pixcharp.com` | Metot | Yol | Açıklama | | --- | --- | --- | | GET | `/v1/prices` | Güncel fiyatların tamamını tek yanıtta döndürür. | | GET | `/v1/prices/{symbol}` | Tek bir sembolün fiyatını döndürür. | | GET | `/v1/symbols` | Hesabınızda kullanılabilen sembolleri listeler. | | GET | `/v1/status` | Veri akışının güncelliğini ve durumunu gösterir. | ### cURL ```bash curl https://api.pixcharp.com/v1/prices/HAS \ -H "X-API-Key: $PIXCHARP_API_KEY" ``` Aynı istek JavaScript, Python, PHP ve dokuz dilde daha: https://docs.pixcharp.com/kod-ornekleri ``` GET https://api.pixcharp.com/health/live GET https://api.pixcharp.com/health/ready ``` ## Yanıtlar `alis` alış, `satis` satış fiyatıdır. `stale: true`, verinin beklenenden eski olduğunu gösterir. ```json { "version": "v1", "asOfUtc": "2026-08-05T10:24:13Z", "source": "harem", "stale": false, "data": [ { "symbol": "HAS", "alis": 6127.46, "satis": 6155.99, "kapanis": null, "acilis": null, "asOfUtc": "2026-08-05T10:24:13Z", "source": "harem", "stale": false } ] } ``` ## Bağlantılar - Dokümantasyon ana sayfası: https://docs.pixcharp.com - Ürün sayfası ve planlar: https://pixcharp.com/tr/harem-altin-api - Müşteri paneli: https://panel.pixcharp.com/tr/api/giris - JavaScript/TypeScript istemcisi (açık kaynak): https://github.com/Baristopal/harem-altin-api - English version: https://docs.pixcharp.com/en/rest-api.md - İletişim: hello@pixcharp.com --- # WebSocket ile canlı altın fiyatı akışı > wss://api.pixcharp.com/v1/stream ile canlı altın ve döviz fiyatı akışı: bağlantı, snapshot ve prices mesajları, sembol aboneliği, kota ve WebSocket hata kodları. Kaynak: https://docs.pixcharp.com/websocket · Son güncelleme: 2026-11-27 Fiyatları sürekli sorgulamak yerine değiştikçe alın. Akış bağlanınca tüm fiyatları, sonra yalnızca değişenleri en fazla saniyede bir gönderir. ## Bağlantı ve kota Pro ve Business planlarında `wss://api.pixcharp.com/v1/stream` adresine düz bir WebSocket bağlantısı açabilirsiniz. REST ile aynı API anahtarını kullanın. Bağlanınca tüm fiyatlar tek bir `snapshot` mesajında gelir. Sonra fiyat değiştikçe en fazla saniyede bir `prices` mesajı gelir; bu mesaj o saniyede değişen sembollerin son değerlerini içerir. Her `snapshot` ve `prices` mesajı aylık kotanızdan 1 istek düşer; `ping`, `pong`, `error` ve `subscribed` ücretsizdir, fiyatın değişmediği saniyeler de bir şey harcamaz. Kota REST çağrıları ve tüm açık bağlantılar arasında ortaktır. Bağlantı kurulumu ayrıca dakika başı limite sayılır. ### Node.js ```javascript // Kurulum: npm install ws import WebSocket from "ws"; const ws = new WebSocket("wss://api.pixcharp.com/v1/stream", { headers: { "X-API-Key": process.env.PIXCHARP_API_KEY }, }); ws.on("open", () => { // İsteğe bağlı: yalnızca ihtiyacınız olan semboller. [] veya ["*"] hepsini geri getirir. ws.send(JSON.stringify({ type: "subscribe", symbols: ["HAS", "USDTRY"] })); }); ws.on("message", (raw) => { const message = JSON.parse(raw.toString()); if (message.type === "snapshot") console.log(message.data.length, "sembol"); if (message.type === "prices") for (const row of message.data) console.log(row.symbol, row.satis); }); ``` ### Python ```python # Kurulum: pip install "websockets>=14" import asyncio import json import os import websockets async def main(): async with websockets.connect( "wss://api.pixcharp.com/v1/stream", additional_headers={"X-API-Key": os.environ["PIXCHARP_API_KEY"]}, ) as ws: # İsteğe bağlı: yalnızca ihtiyacınız olan semboller. [] veya ["*"] hepsini geri getirir. await ws.send(json.dumps({"type": "subscribe", "symbols": ["HAS", "USDTRY"]})) async for raw in ws: message = json.loads(raw) if message["type"] == "prices": for row in message["data"]: print(row["symbol"], row["satis"]) asyncio.run(main()) ``` ### Go ```go // Kurulum: go get github.com/gorilla/websocket package main import ( "fmt" "net/http" "os" "github.com/gorilla/websocket" ) func main() { header := http.Header{"X-API-Key": {os.Getenv("PIXCHARP_API_KEY")}} conn, _, err := websocket.DefaultDialer.Dial("wss://api.pixcharp.com/v1/stream", header) if err != nil { panic(err) } defer conn.Close() // İsteğe bağlı: yalnızca ihtiyacınız olan semboller. [] veya ["*"] hepsini geri getirir. conn.WriteJSON(map[string]any{"type": "subscribe", "symbols": []string{"HAS", "USDTRY"}}) for { var message struct { Type string `json:"type"` Data []map[string]any `json:"data"` } if err := conn.ReadJSON(&message); err != nil { panic(err) } if message.Type == "prices" { for _, row := range message.Data { fmt.Println(row["symbol"], row["satis"]) } } } } ``` ### C# ```csharp // .NET 7+ using System.Net.WebSockets; using System.Text; using System.Text.Json; using var ws = new ClientWebSocket(); ws.Options.SetRequestHeader("X-API-Key", Environment.GetEnvironmentVariable("PIXCHARP_API_KEY")); await ws.ConnectAsync(new Uri("wss://api.pixcharp.com/v1/stream"), CancellationToken.None); // İsteğe bağlı: yalnızca ihtiyacınız olan semboller. [] veya ["*"] hepsini geri getirir. var subscribe = Encoding.UTF8.GetBytes("""{"type":"subscribe","symbols":["HAS","USDTRY"]}"""); await ws.SendAsync(subscribe, WebSocketMessageType.Text, true, CancellationToken.None); var buffer = new byte[64 * 1024]; while (ws.State == WebSocketState.Open) { using var message = new MemoryStream(); WebSocketReceiveResult result; do { result = await ws.ReceiveAsync(buffer, CancellationToken.None); message.Write(buffer, 0, result.Count); } while (!result.EndOfMessage); using var json = JsonDocument.Parse(message.ToArray()); if (json.RootElement.GetProperty("type").GetString() == "prices") foreach (var row in json.RootElement.GetProperty("data").EnumerateArray()) Console.WriteLine($"{row.GetProperty("symbol")} {row.GetProperty("satis")}"); } ``` ### Browser ```javascript // Tarayıcılar WebSocket başlığı gönderemez, bu yüzden anahtar URL'de taşınır. // Ayrı bir anahtar ve IP whitelist kullanın; sunucudan bağlanırken başlığı tercih edin. const ws = new WebSocket("wss://api.pixcharp.com/v1/stream?apiKey=" + encodeURIComponent(key)); ws.onmessage = (event) => { const message = JSON.parse(event.data); if (message.type === "prices") for (const row of message.data) console.log(row.symbol, row.satis); }; ``` ## Mesajlar ```text // Bağlanınca ve her "subscribe" mesajından sonra {"type":"snapshot","asOfUtc":"2026-11-14T10:24:13Z","market":"open","data":[{"symbol":"HAS","alis":6127.46,"satis":6155.99,...}]} // Fiyat değiştikçe, en fazla saniyede bir (kotadan 1 istek) {"type":"prices","asOfUtc":"2026-11-14T10:24:14Z","data":[{"symbol":"USDTRY","alis":41.1,"satis":41.2,"asOfUtc":"2026-11-14T10:24:14Z","source":"harem","stale":false}]} // 30 saniyede bir (yanıt gerekmez) {"type":"ping","ts":"2026-11-14T10:24:43Z"} // Hatalı istemci mesajı; bağlantı açık kalır {"type":"error","code":"invalid_symbol","message":"..."} ``` ## Bağlantı hataları | HTTP | Kod | Anlamı | | --- | --- | --- | | 400 | `websocket_required` | İstek bir WebSocket bağlantısı değil. | | 403 | `websocket_not_included` | Planınızda WebSocket bağlantısı yok (Starter). | | 403 | `ip_not_allowed` | Adres IP whitelist'inizde değil. | | 429 | `websocket_connection_limit` | Planınızın tüm bağlantıları açık. Tüm anahtarlardan açılan bağlantılar birlikte sayılır. | | 429 | `monthly_quota_exceeded` | Aylık kotanız doldu. Ayın 1'inde (UTC) sıfırlanana kadar yeni bağlantı açılamaz. | ## Bağlantı kontrolü ve yeniden bağlanma Açık bağlantılar 60 saniyede bir yeniden kontrol edilir. Anahtar iptal edilirse, plan değişirse, adres whitelist'ten çıkarılırsa ya da aylık kota dolarsa sunucu bir `error` mesajı gönderir ve bağlantıyı 1008 koduyla kapatır. Piyasa sürekli hareketliyken sürekli açık tek bir bağlantı Pro planında yaklaşık 11 gün, Business'ta ayın tamamı yeter. Bağlantı kapandığında bekleme süresini giderek artırarak yeniden bağlanın. ## Bağlantılar - Dokümantasyon ana sayfası: https://docs.pixcharp.com - Ürün sayfası ve planlar: https://pixcharp.com/tr/harem-altin-api - Müşteri paneli: https://panel.pixcharp.com/tr/api/giris - JavaScript/TypeScript istemcisi (açık kaynak): https://github.com/Baristopal/harem-altin-api - English version: https://docs.pixcharp.com/en/websocket.md - İletişim: hello@pixcharp.com --- # Hata kodları ve limitler > Harem Altın API hata kodları (401, 403, 404, 429, 503), dakika başı istek limiti, aylık kota ve X-RateLimit-Remaining, X-Quota-Remaining yanıt başlıkları. Kaynak: https://docs.pixcharp.com/hata-kodlari · Son güncelleme: 2026-11-27 Hatalar bir HTTP durum kodu ve makine tarafından okunabilir bir hata koduyla döner. Limitler plana göre değişir; kalan hakkınız yanıt başlıklarında görünür. ## Hata kodları Başarılı ve sınırlandırılmış yanıtlar, mümkün olduğunda API sürümünü, dakika başı limiti ve aylık kota durumunu başlıklarda döndürür. | HTTP | Kod | Anlamı | | --- | --- | --- | | 401 | `api_key_required / invalid_api_key` | Kimlik doğrulama eksik ya da geçersiz. | | 403 | `revoked_api_key / inactive_client / ip_not_allowed` | Anahtar veya hesap devre dışı ya da adres whitelist'te değil. | | 404 | `unknown_symbol` | Sembol mevcut değil. | | 429 | `rate_limit_exceeded / monthly_quota_exceeded` | İstekleri yavaşlatın ya da planınızı yükseltin. | | 503 | `price_feed_empty` | Kaynak fiyat verisi henüz hazır değil. | Yanıt başlıkları: `X-API-Version`, `X-RateLimit-Remaining`, `X-Quota-Remaining` ## Plan limitleri REST çağrıları ve WebSocket mesajları aynı aylık kotayı paylaşır; kota ayın 1'inde (UTC) sıfırlanır. | Plan | Aylık istek | Dakika başı limit | WebSocket bağlantısı | İzinli IP | | --- | --- | --- | --- | --- | | Deneme | 10.000 | 30 | 1 | 1 | | Starter | 200.000 | 60 | - | 1 | | Pro | 1.000.000 | 180 | 2 | 4 | | Business | 5.000.000 | 600 | 10 | 10 | ## Bağlantılar - Dokümantasyon ana sayfası: https://docs.pixcharp.com - Ürün sayfası ve planlar: https://pixcharp.com/tr/harem-altin-api - Müşteri paneli: https://panel.pixcharp.com/tr/api/giris - JavaScript/TypeScript istemcisi (açık kaynak): https://github.com/Baristopal/harem-altin-api - English version: https://docs.pixcharp.com/en/errors-and-limits.md - İletişim: hello@pixcharp.com --- # Kod örnekleri > Harem Altın API için cURL, JavaScript, Python, PHP, Go, Java, C#, Ruby, Rust, Kotlin, Swift ve Dart istek örnekleri ve açık kaynak harem-altin-api istemcisi. Kaynak: https://docs.pixcharp.com/kod-ornekleri · Son güncelleme: 2026-11-27 Aynı isteği on iki dilde gösteren, kopyalayıp çalıştırabileceğiniz örnekler. JavaScript veya TypeScript kullanıyorsanız açık kaynak istemci REST ve WebSocket'i tek pakette sunar. ## JavaScript / TypeScript istemcisi JavaScript veya TypeScript kullanıyorsanız açık kaynak `harem-altin-api` istemcisi REST ve WebSocket'i sizin yerinize yönetir. npm: https://www.npmjs.com/package/harem-altin-api · GitHub: https://github.com/Baristopal/harem-altin-api ```javascript // npm install harem-altin-api import { createClient } from "harem-altin-api"; const client = createClient({ apiKey: process.env.PIXCHARP_API_KEY }); const has = await client.getPrice("HAS"); console.log(has.symbol, has.alis, has.satis); ``` ## REST istek örnekleri Tek bir sembolün fiyatını isteyen `GET /v1/prices/HAS` çağrısı on iki dilde. Anahtarı kodun içine yazmak yerine `PIXCHARP_API_KEY` ortam değişkeninde tutun. ### cURL ```bash curl https://api.pixcharp.com/v1/prices/HAS \ -H "X-API-Key: $PIXCHARP_API_KEY" ``` ### JavaScript ```javascript // Node.js 18+, Deno, Bun const response = await fetch("https://api.pixcharp.com/v1/prices/HAS", { headers: { "X-API-Key": process.env.PIXCHARP_API_KEY }, }); if (!response.ok) throw new Error(`HTTP ${response.status}`); const price = await response.json(); console.log(price.symbol, price.alis, price.satis); ``` ### Python ```python # Kurulum: pip install requests import os import requests response = requests.get( "https://api.pixcharp.com/v1/prices/HAS", headers={"X-API-Key": os.environ["PIXCHARP_API_KEY"]}, timeout=10, ) response.raise_for_status() price = response.json() print(price["symbol"], price["alis"], price["satis"]) ``` ### PHP ```php true, CURLOPT_HTTPHEADER => ["X-API-Key: " . getenv("PIXCHARP_API_KEY")], CURLOPT_TIMEOUT => 10, ]); $price = json_decode(curl_exec($client), true); curl_close($client); echo $price["symbol"], " ", $price["alis"], " ", $price["satis"], PHP_EOL; ``` ### Go ```go package main import ( "encoding/json" "fmt" "net/http" "os" ) type Price struct { Symbol string `json:"symbol"` Alis float64 `json:"alis"` Satis float64 `json:"satis"` AsOfUtc string `json:"asOfUtc"` Stale bool `json:"stale"` } func main() { req, _ := http.NewRequest(http.MethodGet, "https://api.pixcharp.com/v1/prices/HAS", nil) req.Header.Set("X-API-Key", os.Getenv("PIXCHARP_API_KEY")) res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() var price Price if err := json.NewDecoder(res.Body).Decode(&price); err != nil { panic(err) } fmt.Println(price.Symbol, price.Alis, price.Satis) } ``` ### Java ```java // Java 11+ import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class Main { public static void main(String[] args) throws Exception { HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.pixcharp.com/v1/prices/HAS")) .header("X-API-Key", System.getenv("PIXCHARP_API_KEY")) .GET() .build(); HttpResponse response = HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` ### C# ```csharp // .NET 6+ using System.Net.Http.Json; using var http = new HttpClient { BaseAddress = new Uri("https://api.pixcharp.com") }; http.DefaultRequestHeaders.Add("X-API-Key", Environment.GetEnvironmentVariable("PIXCHARP_API_KEY")); var price = await http.GetFromJsonAsync("/v1/prices/HAS"); Console.WriteLine($"{price!.Symbol} {price.Alis} {price.Satis}"); record Price(string Symbol, decimal Alis, decimal Satis, DateTime AsOfUtc, bool Stale); ``` ### Ruby ```ruby require "net/http" require "json" uri = URI("https://api.pixcharp.com/v1/prices/HAS") request = Net::HTTP::Get.new(uri) request["X-API-Key"] = ENV.fetch("PIXCHARP_API_KEY") response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) } price = JSON.parse(response.body) puts "#{price["symbol"]} #{price["alis"]} #{price["satis"]}" ``` ### Rust ```rust // Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, serde_json = "1", // tokio = { version = "1", features = ["full"] } #[tokio::main] async fn main() -> Result<(), Box> { let price: serde_json::Value = reqwest::Client::new() .get("https://api.pixcharp.com/v1/prices/HAS") .header("X-API-Key", std::env::var("PIXCHARP_API_KEY")?) .send() .await? .error_for_status()? .json() .await?; println!("{} {} {}", price["symbol"], price["alis"], price["satis"]); Ok(()) } ``` ### Kotlin ```kotlin // Anahtarı uygulama paketine gömmeyin; bu isteği kendi sunucunuzdan yapın. import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse fun main() { val request = HttpRequest.newBuilder(URI("https://api.pixcharp.com/v1/prices/HAS")) .header("X-API-Key", System.getenv("PIXCHARP_API_KEY")) .build() val response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()) println(response.body()) } ``` ### Swift ```swift // Anahtarı uygulama paketine gömmeyin; bu isteği kendi sunucunuzdan yapın. import Foundation struct Price: Decodable { let symbol: String let alis: Double let satis: Double } var request = URLRequest(url: URL(string: "https://api.pixcharp.com/v1/prices/HAS")!) request.setValue(ProcessInfo.processInfo.environment["PIXCHARP_API_KEY"], forHTTPHeaderField: "X-API-Key") let (data, _) = try await URLSession.shared.data(for: request) let price = try JSONDecoder().decode(Price.self, from: data) print(price.symbol, price.alis, price.satis) ``` ### Dart ```dart // Anahtarı uygulama paketine gömmeyin; bu isteği kendi sunucunuzdan yapın. // Kurulum: dart pub add http import 'dart:convert'; import 'dart:io'; import 'package:http/http.dart' as http; Future main() async { final response = await http.get( Uri.parse('https://api.pixcharp.com/v1/prices/HAS'), headers: {'X-API-Key': Platform.environment['PIXCHARP_API_KEY']!}, ); final price = jsonDecode(response.body) as Map; print('${price['symbol']} ${price['alis']} ${price['satis']}'); } ``` WebSocket bağlantısı için aynı dillerdeki örnekler WebSocket akışı sayfasında: https://docs.pixcharp.com/websocket ## Bağlantılar - Dokümantasyon ana sayfası: https://docs.pixcharp.com - Ürün sayfası ve planlar: https://pixcharp.com/tr/harem-altin-api - Müşteri paneli: https://panel.pixcharp.com/tr/api/giris - JavaScript/TypeScript istemcisi (açık kaynak): https://github.com/Baristopal/harem-altin-api - English version: https://docs.pixcharp.com/en/code-examples.md - İletişim: hello@pixcharp.com