POST /cards/resolve curl --fail-with-body --silent --show-error \
-X POST \
-H "Authorization: Bearer $MEREU_API_KEY" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
"https://mereu.md/api/v1/cards/resolve" \
--data-binary @- <<JSON
{
"location_id": "$LOCATION_ID",
"card_code": "$CARD_CODE"
}
JSON
// 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/cards/resolve");
const body = {
"location_id": env("LOCATION_ID"),
"card_code": env("CARD_CODE")
};
const response = await fetch(url, {
method: "POST",
redirect: "error",
signal: AbortSignal.timeout(15000),
headers: {
"Authorization": "Bearer " + env("MEREU_API_KEY"),
"Accept": "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(body)
});
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/cards/resolve"
body = {
"location_id": env("LOCATION_ID"),
"card_code": env("CARD_CODE")
}
headers = {
"Authorization": "Bearer " + env("MEREU_API_KEY"),
"Accept": "application/json",
"Content-Type": "application/json"
}
request = Request(url, method="POST", headers=headers,
data=json.dumps(body, separators=(",", ":")).encode("utf-8"))
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.
Date ilustrative din verificări izolate. Identificatorii nu aparțin contului tău.