TypeScript SDK
import { Creem } from "creem";
const creem = new Creem({
apiKey: process.env["CREEM_API_KEY"] ?? "",
});
async function run() {
const result = await creem.discounts.search(1, 10, "prod_1234567890", undefined, undefined, "2024-01-01T00:00:00Z", "2024-12-31T23:59:59Z");
console.log(result);
}
run();curl --request GET \
--url https://api.creem.io/v1/discounts/search \
--header 'x-api-key: <api-key>'import requests
url = "https://api.creem.io/v1/discounts/search"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.creem.io/v1/discounts/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.creem.io/v1/discounts/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.creem.io/v1/discounts/search"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.creem.io/v1/discounts/search")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.creem.io/v1/discounts/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"items": [
{
"id": "<string>",
"mode": "test",
"object": "discount",
"status": "active",
"name": "Holiday Sale",
"code": "HOLIDAY2024",
"type": "percentage",
"amount": 20,
"currency": "USD",
"percentage": 15,
"expiry_date": "2024-12-31T23:59:59Z",
"max_redemptions": 100,
"duration": "repeating",
"duration_in_months": 6,
"applies_to_products": [
"prod_123",
"prod_456"
],
"redeem_count": 15
}
],
"pagination": {
"total_records": 0,
"total_pages": 0,
"current_page": 1,
"next_page": 2,
"prev_page": null
}
}Discount Code
Search and list all discounts
Search and list discount codes for a store with filters and pagination.
GET
/
v1
/
discounts
/
search
TypeScript SDK
import { Creem } from "creem";
const creem = new Creem({
apiKey: process.env["CREEM_API_KEY"] ?? "",
});
async function run() {
const result = await creem.discounts.search(1, 10, "prod_1234567890", undefined, undefined, "2024-01-01T00:00:00Z", "2024-12-31T23:59:59Z");
console.log(result);
}
run();curl --request GET \
--url https://api.creem.io/v1/discounts/search \
--header 'x-api-key: <api-key>'import requests
url = "https://api.creem.io/v1/discounts/search"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.creem.io/v1/discounts/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.creem.io/v1/discounts/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.creem.io/v1/discounts/search"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.creem.io/v1/discounts/search")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.creem.io/v1/discounts/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"items": [
{
"id": "<string>",
"mode": "test",
"object": "discount",
"status": "active",
"name": "Holiday Sale",
"code": "HOLIDAY2024",
"type": "percentage",
"amount": 20,
"currency": "USD",
"percentage": 15,
"expiry_date": "2024-12-31T23:59:59Z",
"max_redemptions": 100,
"duration": "repeating",
"duration_in_months": 6,
"applies_to_products": [
"prod_123",
"prod_456"
],
"redeem_count": 15
}
],
"pagination": {
"total_records": 0,
"total_pages": 0,
"current_page": 1,
"next_page": 2,
"prev_page": null
}
}Authorizations
API key for authentication. You can find your API key in the Creem dashboard under Settings > API Keys.
Query Parameters
The page number for pagination.
Example:
1
The number of items per page.
Example:
10
Filter discounts that apply to a specific product.
Example:
"prod_1234567890"
Filter by discount status.
Available options:
active, deleted Filter by discount type.
Available options:
percentage, fixed Filter discounts created after this date.
Example:
"2024-01-01T00:00:00Z"
Filter discounts created before this date.
Example:
"2024-12-31T23:59:59Z"