Say a coupon site in Leeds gets 300 visits a day. Its kitchenware page lists SAVE10 for a £40 kettle, but the promotion ended yesterday. A coupon API can deliver updated offer records without manual copying. Your import rules determine whether that update reaches the page before another shopper tries the code.
Receiving data is only the start. You need to decide which records deserve publication and keep them current when a request fails. This guide covers source selection, a usable data contract, scheduled imports and checks that measure quality instead of feed size.
What does a coupon API actually provide?
A developer searches for discount data and finds an endpoint that creates checkout coupons. It looks relevant, but it doesn’t supply other merchants’ offers for a publishing website. That distinction changes the integration you need.
For a coupon publisher, a coupon API is an application programming interface that lets software request machine-readable offer information. A coupon data feed is the dataset delivered through that interface or a downloadable file. It may contain codes, code-free deals or both. A merchant’s promotion-management API serves a different purpose: creating or administering discounts in that merchant’s checkout.
couponPHP is a self-hosted PHP coupon and deal website script, a content management system for running your own offer site. Its couponFeed service supplies aggregated coupon and deal data, with JSON access and cron-based imports. That illustrates the separation: the publishing software stores and displays offers; the feed supplies records that still need sensible import and display rules.
Before comparing providers, you’ll want to establish whether an endpoint returns publishable offers, whether your account can access the intended merchants, and whether the response contains codes or just promotional links. Those answers prevent a technically successful integration from filling your site with unusable data.
Which source type fits your publishing plan?
Say your site covers British outdoor shops, but a proposed feed’s largest category is US restaurant deals. Its record count won’t tell you whether it serves your readers. Source choice starts with merchant and country coverage.
| Source type | What you receive | What you need to check |
|---|---|---|
| Affiliate network API | Offers from participating advertisers available to your publisher account | Merchant approval, permitted promotion methods and publisher-specific tracking |
| Aggregated feed, such as couponFeed | Offers collected into a common format across sources | Provenance, checking method, permitted reuse and removal handling |
| Merchant feed or direct API | Offers supplied by one retailer, sometimes as CSV or XML files | Publication permission, date semantics, restrictions and attribution arrangements |
Network APIs are useful when you already have advertiser relationships. But feed access and permission to earn commission aren’t interchangeable. Your affiliate program selection should match the stores you intend to publish.
Aggregation can reduce the number of formats you maintain. The trade-off is another layer between you and the original offer, so you’ll need to know where corrections originate and how quickly withdrawals reach you. A direct merchant feed gives you a closer contact for missing terms, but each integration has its own maintenance work.
For a small launch, one source with relevant merchants is easier to assess than several overlapping feeds. Before paying, you can request sample records for your actual store list and written rules for storing, displaying and modifying the data. Your agreement should also clarify any separate reuse restrictions on merchant logos and descriptions. API credentials aren’t a publication licence.
Which offer fields should your database keep?
Two feeds describe SAVE10 differently: one says “10% off” and another says “new customers, minimum basket £40.” If you import only the headline and code, you discard the reason a returning customer can’t redeem it.
A written data contract gives each field a meaning before you map it into your database. Retaining the original record alongside normalized values lets you investigate a dispute without guessing what the source sent.
| Field | Publication rule |
|---|---|
| Source and offer ID | Both are needed; an ID may be unique only within its source |
| Merchant ID, domain and country | Each maps to your own store ID, with regional storefronts distinguished |
| Offer type and code | Code-based coupons and automatic deals stay separate; code characters remain unchanged |
| Start and end timestamps | The contract identifies offset and inclusive or exclusive end semantics |
| Terms and discount | Restrictions include minimum spend, exclusions, customer eligibility, value and currency |
| Exclusivity | The record needs scope, evidence and any permission to make the claim |
| Destination and tracking URL | The shopping destination stays separate from the monetized link |
| Source update and import times | Provider changes remain distinguishable from your own retrieval activity |
| Verification time and method | The record identifies what was checked, when, and under which conditions |
| Status and withdrawal reason | States cover active, withdrawn, expired and review records |
An imported record isn’t automatically verified. A provider may have checked that a landing page loads rather than tested the code at checkout. You’ll need different labels for those checks. An “exclusive” label needs supported scope, such as an offer restricted to your publisher account.
Missing values should remain distinguishable. A null expiry means unknown; it doesn’t mean the offer lasts forever. For an automatic deal, a null code can be correct. For a coupon that requires a code, it should trigger review.
A JSON record your importer can reason about
A feed sends an offer ID as a number, then another source sends an ID with leading zeros. Converting both into integers can destroy identity. A provider-neutral internal record avoids that problem by treating identifiers as strings.
Here’s a fictional normalized record, not an endpoint response or a product-specific schema:
{
"source": "sample_aggregate",
"offer_id": "00042",
"merchant_id": "kitchen_uk",
"merchant_domain": "shop.example",
"country": "GB",
"type": "coupon",
"code": "SAVE10",
"discount_percent": 10,
"minimum_spend": "40.00",
"currency": "GBP",
"starts_at": "2027-03-01T00:00:00Z",
"expires_at": "2027-04-01T00:00:00Z",
"expiry_semantics": "exclusive",
"terms": "Kettles only; minimum basket GBP 40; excludes clearance.",
"exclusive_scope": null,
"destination_url": "https://shop.example/kettles",
"tracking_url": "https://track.example/click?offer=00042&publisher=demo",
"source_updated_at": "2027-03-01T08:00:00Z",
"verified_at": "2027-03-01T08:05:00Z",
"verification_method": "landing_page_check",
"status": "active"
}
The IETF’s JSON standard, RFC 8259 (2017), requires UTF-8 for exchange outside closed systems and recommends unique object member names.[1] Rejecting duplicate keys avoids ambiguity over which expiry or tracking value your parser retains. Valid JSON still needs field validation; syntax doesn’t prove offer quality.
RFC 3339 (2002) defines timestamps with a date, time and UTC marker or numeric offset.[2] You can store normalized instants in UTC while retaining source date rules. If a merchant supplies only “ends March 31,” you need its timezone and end-of-day convention before converting it. You can’t safely infer those from your server’s location.
Sync with cron without publishing a half-finished import
An import receives the first page, times out on the second, and reports success. Your store page now combines fresh offers with stale ones. Running that job more often won’t fix the failure rule.
Cron is a scheduler that starts your importer at specified times. Visitors should read your local database rather than wait for a live provider request. This keeps page delivery independent of feed availability. Existing feed integration plugins can reduce connector work, but the operating checks still matter.
A dependable import follows this sequence:
- The job acquires a lock so another run can’t overlap, then reads the last committed checkpoint.
- Required pages enter staging, with timeouts and a bounded request budget.
- Validation maps merchants and quarantines failed records with a reason.
- Upserts update existing source IDs and insert genuinely new ones.
- Explicit withdrawals take effect before the completed batch and its checkpoint become visible together.
- The completion log records counts, rejected records and elapsed time; failures or unexpected changes trigger alerts.
For a small database, a transaction may cover publication and checkpointing. For a larger import, staging tables and a batch pointer can make the new dataset visible together. Either approach prevents readers from seeing an incomplete snapshot.
An illustrative Linux cron entry starts a custom importer every 15 minutes:
*/15 * * * * /usr/bin/php /srv/coupon-site/bin/import-offers.php >> /var/log/coupon-import.log 2>&1
The paths are examples, not shipped commands. Your host needs permission to run the script and write the log, and you’ll need log rotation. Credentials belong in protected server configuration. The cron setup guide provides related scheduling context.
For delta feeds, which return changes since a checkpoint, the provider’s cursor is preferable where available. With timestamp filters, a documented overlap window can catch late updates; idempotent upserts make reprocessing safe. Idempotent means processing the same record again leaves the same result. Progress should commit only after the corresponding records are durable.
For full snapshots, missing records should become withdrawn only after a complete, validated response for the same scope, and only if the provider defines absence as removal. A country filter change or failed page mustn’t delete your catalog. Periodic full reconciliation helps detect changes a delta run missed.
Deduplicate offers without losing their differences
SAVE10 arrives through a network and an aggregator. Later, the merchant uses SAVE10 again for a different promotion. Matching on code alone either creates duplicates or merges offers that shouldn’t share a record.
Within one source, (source, offer_id) makes a suitable update key, backed by a database uniqueness rule. That’s your first defence against duplicate cron runs. Across sources, a match should consider canonical merchant, country, offer type, code, validity window and restrictions before joining records into one displayed offer.
Code matching should preserve the original characters. Changing case or removing internal spaces can damage a code unless the merchant’s rules confirm those changes are safe. Similar titles can suggest a match, but they aren’t enough to merge code-free deals.
Keeping all source relationships behind the displayed offer lets you trace conflicting data. That way, a withdrawal from one source won’t erase another valid record without review. Conflicting dates or terms should trigger a defined precedence rule or manual check, rather than a field-by-field mixture that no source actually supplied.
Your tracking route should follow your approved advertiser relationship and offer terms. Deduplication should remove repeated presentation, not quietly replace your publisher attribution.
Expiry must keep working when imports stop
A promotion ends at midnight, but the feed is unavailable until morning. If expiry happens only during imports, your page still invites shoppers to use a dead code. This failure is predictable.
A local validity rule keeps expiry independent. With an exclusive end timestamp, an offer is eligible only while starts_at <= now < expires_at, subject to its status and terms. An expiry worker should remove expired offers from active listings and invalidate cached pages. The display query should also exclude them, so a delayed worker can’t expose them.
The JSON example expires at the start of April 1 UTC. That’s an explicit boundary. A source’s inclusive calendar end date needs conversion using its documented timezone, including daylight-saving rules where relevant.
Unknown expiry requires a different policy. You could set a review deadline based on offer risk and keep “expiry unknown” separate from “expired.” A made-up end date would mislead shoppers. Short promotions need tighter review than ongoing shipping deals.
During an outage, last-known records can stay active only while they satisfy your expiry and stale-data policies. The outage should trigger an operator alert and a delayed-source status, without a claim of recent verification. Newsletter generation needs the same validity check: yesterday’s accepted import can contain today’s expired offers.
Respect rate limits and keep credentials off public pages
A 15-minute schedule sounds modest until each run requests 20 pages. In this hypothetical setup, daily requests equal 20 × 4 runs per hour × 24 hours = 1,920, before retries, authentication or other jobs. The average hides any burst at startup.
Your request budget needs to fit the provider’s documented quota and counting scope. Pacing requests across workers sharing an account leaves capacity for retries; staggered jobs can reduce bursts. A larger page size may help if the endpoint supports it.
The IETF’s RFC 6585 (2012) defines HTTP 429 as “Too Many Requests”; a response may include Retry-After.[3] RFC 9110 (2022) allows that header to contain an HTTP date or a delay in seconds.[4] Your client needs to respect either form. Without it, capped exponential backoff with randomized delay and a retry limit is a reasonable fallback. This means increasing the wait after repeated failures, rather than retrying immediately. Repeated retries won’t fix an invalid credential.
Where supported, ETags and conditional GET requests can avoid downloading unchanged responses. An ETag identifies a response version for later comparison. A 304 response has no content; it isn’t an empty feed.[4] Conditional requests may still count against a quota, so they don’t necessarily buy more calls.
HTTPS with certificate validation protects transport. Tokens belong server-side and shouldn’t appear in logs. Your importer should treat descriptions as untrusted content, restrict allowed URL schemes, and avoid automatically fetching arbitrary feed URLs. These controls reduce the damage a compromised source could cause.
Measure feed quality against offers you can publish
A coupon API advertises a large catalog, but your trial finds mostly stores outside your market. Counting rows rewards the wrong result. You’re paying for useful, attributable offers, not a larger database.
A useful trial uses a fixed merchant list. Your test log needs the sample date, countries and eligibility conditions so another check can reproduce it. These checks separate coverage from operational quality:
| Check | Measurement |
|---|---|
| Merchant coverage | Target stores with usable offers divided by target stores |
| Checkout acceptance | Successful eligible code tests divided by completed eligible tests |
| Duplicate burden | Redundant rows divided by sampled rows, using your matching rule |
| Terms completeness | Records containing the restrictions needed for publication |
| Publication delay | Time from source update to your live page; report median and 95th percentile |
| Attribution | Checked links that retain your intended publisher identity and approved route |
| Withdrawal handling | Whether removed offers disappear after a completed sync |
Suppose 15 of 20 target stores have usable offers: coverage is 15 ÷ 20 × 100 = 75%. If 92 of 100 completed eligible checkout tests accept the code, observed acceptance is 92 ÷ 100 × 100 = 92%. Six redundant rows in a 100-row sample give 6 ÷ 100 × 100 = 6% duplicate burden. These are illustrative results, not industry benchmarks.
You can test relevant baskets without completing unnecessary purchases, while respecting merchant rules. Your log should separate ineligible attempts from genuine failures and disclose the excluded count. That prevents a better-looking percentage from quietly hiding bad results. Repeating checks across categories and days reduces dependence on one sample. One passing basket doesn’t prove every shopper qualifies.
Acceptance rules work best when you set them before reviewing results. For example, you might quarantine every code without terms and require review of unresolved date conflicts. Those are editorial choices. They should reflect the complaints and maintenance work you’re prepared to handle.
Clicks alone don’t validate a feed. Your affiliate measurement plan should separate offer acceptance from tracking performance and earnings. A working discount can still use the wrong affiliate link, while an attributed click can lead to an expired promotion.
Frequently asked questions
What is the difference between an API and a coupon feed?
A downloadable CSV contains offers but doesn’t let you request one store through an endpoint. An API is the interface your software calls; the feed is the dataset. Either delivery method can support publishing. Snapshots, delta updates, withdrawal signals and stable identifiers determine import reliability more than the file format does. Comparing those properties helps you choose a workable source.
Can I use a free source for my coupon website?
A free export might omit restrictions or require advertiser approval you don’t have. You can use it if publication is permitted and its offers meet the relevant merchant and affiliate terms. Free access doesn’t grant unrestricted reuse. Checking and maintenance time matter alongside the number of usable offers; a subscription price alone doesn’t capture your operating cost.
Does a verification timestamp prove a coupon works?
A record checked this morning may only have passed a link test. The timestamp tells you when the stated check happened, not which baskets qualify. Its method and conditions need an accurate label. For checkout tests, your evidence should include country, basket and customer eligibility. A successful test supports those conditions at that time; it isn’t a promise to every shopper.
How often should I refresh coupon data?
An hourly import can miss much of a short flash sale; a rapid poll wastes requests if the provider updates daily. Your interval should reflect source updates, offer duration and quota. Completed imports and publication delay show whether greater frequency would help. Local expiry still needs to run independently, because even a frequent schedule can’t guarantee that the next request will succeed.
Prove one store before importing your whole catalog
A broad launch can conceal a broken withdrawal rule until hundreds of offers go stale. One store gives you a smaller place to expose that fault.
Before expanding, you can follow one offer from retrieval through display and tracking, then confirm its expiry and withdrawal behavior in a test environment. Repeating the same import exposes duplicate creation. A simulated page failure should leave existing records intact. Your first release gate should be specific: no duplicate on rerun, no deletion on partial failure, and no expired offer left active.
References
