curl --fail-with-body --silent --show-error \
-H "Authorization: Bearer $MEREU_API_KEY" \
-H 'Accept: application/json' \
"https://mereu.md/api/v1/account"
// Node.js 24+. Run on your server; set the named environment variables.
const env = (name) => {
const value = process.env[name];
if (!value) throw new Error("Missing environment variable: " + name);
return value;
};
const url = new URL("https://mereu.md/api/v1/account");
const response = await fetch(url, {
method: "GET",
redirect: "error",
signal: AbortSignal.timeout(15000),
headers: {
"Authorization": "Bearer " + env("MEREU_API_KEY"),
"Accept": "application/json"
}
});
const result = await response.json();
if (!response.ok) {
throw Object.assign(new Error(result.error?.code || "API_ERROR"), {
status: response.status,
requestId: result.error?.request_id || response.headers.get("X-Request-Id"),
retryAfter: response.headers.get("Retry-After")
});
}
console.log(JSON.stringify(result, null, 2));
# Python 3, standard library only. Run on your server.
import json
import os
from urllib.parse import quote, urlencode
from urllib.request import Request, build_opener, HTTPRedirectHandler
from urllib.error import HTTPError
def env(name):
value = os.environ.get(name)
if not value:
raise ValueError("Missing environment variable: " + name)
return value
class NoRedirect(HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
return None
url = "https://mereu.md/api/v1/account"
headers = {
"Authorization": "Bearer " + env("MEREU_API_KEY"),
"Accept": "application/json"
}
request = Request(url, method="GET", headers=headers)
try:
with build_opener(NoRedirect()).open(request, timeout=15) as response:
result = json.load(response)
except HTTPError as error:
try:
code = json.load(error).get("error", {}).get("code", "API_ERROR")
except (ValueError, AttributeError):
code = "INVALID_RESPONSE"
raise SystemExit("HTTP " + str(error.code) + ": " + code
+ "; request_id=" + str(error.headers.get("X-Request-Id"))
+ "; retry_after=" + str(error.headers.get("Retry-After"))) from None
print(json.dumps(result, indent=2))
Exemplele JavaScript (Node.js 24+) și Python 3 sunt autonome. Rulează-le pe server și setează variabilele de mediu afișate în cod.
Răspuns JSON · exemplu JSON
{
"data": {
"id": "c16fb1f0-545a-4c99-899c-a3e8f348a96c",
"name": "alpha",
"scopes": [
"customers:read",
"refunds:write",
"checkouts:write",
"programs:read",
"locations:read",
"account:read",
"cards:read",
"purchases:write",
"transactions:read"
],
"access_mode": "active",
"country_code": "US",
"base_currency": "USD",
"default_timezone": "America/New_York",
"allowed_location_ids": [
"9788420f-8230-4e89-a189-6e557783346e"
]
}
}
Date ilustrative din verificări izolate. Identificatorii nu aparțin contului tău.