Calculate a discounted price
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");curl_easy_setopt(hnd, CURLOPT_URL, "https://api.proxyrequest.com/api/v1/coupons/calculate-price");
struct curl_slist *headers = NULL;headers = curl_slist_append(headers, "Authorization: Bearer <token>");headers = curl_slist_append(headers, "Content-Type: application/json");curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{ \"package_id\": \"550e8400-e29b-41d4-a716-446655440002\", \"coupon_code\": \"WELCOME20\", \"data\": 10737418240 }");
CURLcode ret = curl_easy_perform(hnd);using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://api.proxyrequest.com/api/v1/coupons/calculate-price"), Headers = { { "Authorization", "Bearer <token>" }, }, Content = new StringContent("{ \"package_id\": \"550e8400-e29b-41d4-a716-446655440002\", \"coupon_code\": \"WELCOME20\", \"data\": 10737418240 }") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.proxyrequest.com/api/v1/coupons/calculate-price"
payload := strings.NewReader("{ \"package_id\": \"550e8400-e29b-41d4-a716-446655440002\", \"coupon_code\": \"WELCOME20\", \"data\": 10737418240 }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.proxyrequest.com/api/v1/coupons/calculate-price")) .header("Authorization", "Bearer <token>") .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString("{ \"package_id\": \"550e8400-e29b-41d4-a716-446655440002\", \"coupon_code\": \"WELCOME20\", \"data\": 10737418240 }")) .build();HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");RequestBody body = RequestBody.create(mediaType, "{ \"package_id\": \"550e8400-e29b-41d4-a716-446655440002\", \"coupon_code\": \"WELCOME20\", \"data\": 10737418240 }");Request request = new Request.Builder() .url("https://api.proxyrequest.com/api/v1/coupons/calculate-price") .post(body) .addHeader("Authorization", "Bearer <token>") .addHeader("Content-Type", "application/json") .build();
Response response = client.newCall(request).execute();import axios from 'axios';
const options = { method: 'POST', url: 'https://api.proxyrequest.com/api/v1/coupons/calculate-price', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, data: { package_id: '550e8400-e29b-41d4-a716-446655440002', coupon_code: 'WELCOME20', data: 10737418240 }};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://api.proxyrequest.com/api/v1/coupons/calculate-price';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"package_id":"550e8400-e29b-41d4-a716-446655440002","coupon_code":"WELCOME20","data":10737418240}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")val body = RequestBody.create(mediaType, "{ \"package_id\": \"550e8400-e29b-41d4-a716-446655440002\", \"coupon_code\": \"WELCOME20\", \"data\": 10737418240 }")val request = Request.Builder() .url("https://api.proxyrequest.com/api/v1/coupons/calculate-price") .post(body) .addHeader("Authorization", "Bearer <token>") .addHeader("Content-Type", "application/json") .build()
val response = client.newCall(request).execute()use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://api.proxyrequest.com/api/v1/coupons/calculate-price";
let payload = json!({ "package_id": "550e8400-e29b-41d4-a716-446655440002", "coupon_code": "WELCOME20", "data": 10737418240 });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://api.proxyrequest.com/api/v1/coupons/calculate-price \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "package_id": "550e8400-e29b-41d4-a716-446655440002", "coupon_code": "WELCOME20", "data": 10737418240 }'wget --quiet \ --method POST \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --body-data '{ "package_id": "550e8400-e29b-41d4-a716-446655440002", "coupon_code": "WELCOME20", "data": 10737418240 }' \ --output-document \ - https://api.proxyrequest.com/api/v1/coupons/calculate-priceValidates a coupon against the selected package and data amount, then returns both the original and discounted prices without creating an invoice.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Examples
Calculate package discount
{ "package_id": "550e8400-e29b-41d4-a716-446655440002", "coupon_code": "WELCOME20", "data": 10737418240}object
Examples
Example request
package_id=550e8400-e29b-41d4-a716-446655440002&coupon_code=coupon+code&data=1073741824object
Examples
Example request
{ "package_id": "550e8400-e29b-41d4-a716-446655440002", "coupon_code": "coupon code", "data": 1073741824}Responses
Section titled “Responses”The operation completed successfully.
object
Original price in the service’s smallest currency unit.
Price after applying the coupon, in the smallest currency unit.
Examples
Discounted price
{ "price_original": 2500, "price_discounted": 2000, "discount_percentage": 20}The request is malformed or violates a business rule.
Validation and API error payload. Field names may be added dynamically; field errors are returned as arrays of human-readable messages.
object
Stable translation key suitable for client localisation.
Examples
Validation error
{ "non_field_errors": [ "The request could not be processed." ], "translation": "errors.request.invalid"}Authentication credentials are missing, expired, or invalid.
Validation and API error payload. Field names may be added dynamically; field errors are returned as arrays of human-readable messages.
object
Stable translation key suitable for client localisation.
Examples
Authentication required
{ "detail": "Authentication credentials were not provided."}The authenticated account cannot perform this operation.
Validation and API error payload. Field names may be added dynamically; field errors are returned as arrays of human-readable messages.
object
Stable translation key suitable for client localisation.
Examples
Permission denied
{ "detail": "You do not have permission to perform this action."}