The Adility Distribution API is a tool to monetize consumer applications with local offers. The Adility Distribution API is as well capable to work for platforms that host consumer applications for others, like daily deal white label providers, advertising networks and more. The basic flow is simple. You query offers from Adility, promote them to your audience, for prepaid offers you charge the consumer and maintain a revenue share from each sale/transaction. Basic Flow
There're also more advanced use cases:
Basic WorkflowQuery OffersGET /offers?query_parameters Returns a list of offers from The Adility matching the query parameters. Query ParametersYou can run queries with a combination of 3 parameter groups:
Filtering This set of query parameters allows you to get offers matching your conditions.
where location parameters are:
Take a look at a few sample queries below. GET /offers?city=san%20francisco&state_code=CA&radius=23&types=deal&recently_closed=5 curl -k -X GET -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your_api_key>" 'http://testapi.adility.com/distribution/beta/offers?city=san%20francisco&state_code=CA&radius=23&types=deal&recently_closed=5' Recently published gift cards and deals from fitness centers and spa salons in London: GET /offers?lat=51.508608&lng=-0.128349&radius=20&categories=1587367777,1765435254&types=gift_card,deal&recently_published=3 curl -k -X GET -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your_api_key>" 'http://testapi.adility.com/distribution/beta/offers?lat=51.508608&lng=-0.128349&radius=20&categories=1587367777,1765435254&types=gift_card,deal&recently_published=3' GET /offers?postal_code=V4E%202A9&country_code=CA&radius=100&categories=658203330&types=coupon curl -k -X GET -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your_api_key>" 'http://testapi.adility.com/distribution/beta/offers?postal_code=V4E%202A9&country_code=CA&radius=100&categories=658203330&types=coupon' Class B deal in Atlanta: GET /offers? city=atlanta&state_code=GA&radius=10&types=deal&class=B curl -k -X GET -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your_api_key>" 'http://testapi.adility.com/distribution/beta/offers?city=atlanta&state_code=GA&radius=10&types=deal&class=B' Pagination You can break result set onto pages by setting two pagination parameters:
Sorting By setting a query parameter sort_by you define sorting for the result set. You can sort by the following offer attribute:
Each attribute can be followed by +asc or +desc keys to set the order. The key +asc is used be default. All sorting parameters are separated by comma. Check queries with sorting parameters below.Sample 1 GET /offers?{filtering}&per_page=20&page=8&sort_by=price+desc,quantity_in_stock curl -k -X GET -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your_api_key>" 'http://testapi.adility.com/distribution/beta/offers?city=atlanta&state_code=GA&radius=10&per_page=20&page=8&sort_by=price+desc,quantity_in_stock' Sample 2 GET /offers?{filtering}&sort_by=published_at+desc,end_date+desc,value+desc curl -k -X GET -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your_api_key>" 'http://testapi.adility.com/distribution/beta/offers?city=atlanta&state_code=GA&radius=10&sort_by=published_at+desc,end_date+desc,value+desc' Result Set Sample in XML <?xml version="1.0" encoding="UTF-8"?> <response> <status>OK</status> <page>3</page> <per_page>100</per_page> <total_pages>10</total_pages> <total_items>948</total_items> <sort_by>sort_by=published_at+desc,end_date+desc,value+desc</sort_by> <offers> ... </offers> </response> You can examine the following attributes for number of pages and number of items in the result set:
Missing Offer AttributesOffers in the result set don't contain attributes related to contact information of an advertiser. All missing attributes go under advertiser attribute of offers:
In order to get these attributes for a specific offer you need to query the offer by offer_id .Get Offer DetailsGET /offers/<offer_id> curl -k -X GET -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your_api_key>" 'http://testapi.adility.com/distribution/beta/offers/<offer_id>' When you query an offer by offer_id the result set contains all attributes of the offer including those that are missing in general query.Place OrderWhen a customer purchases an offer your application creates an order on your end for your records as well as passes the order along to Adility. Aside to secondary attributes the order should containoffer_id and quantity which define the offer and how many vouchers for it has been bought by the customer.In general, customers can purchase more then one offer within a single order. That's why orders have the items attribute of OrderItem which represents a single offer within the order.RequestJSON { "order": { "order_number": "1234-234", "customer_name": "John Smith", "items": [ { "offer_id": "0a3f749808c168528ba01a911ea63ee99a1eee3a7a6787dbd2159ebb6f4d372b", "quantity": "3" } ] } } ResponseJSON HTTP/1.1 200 OK { "status": "OK", "order": { "id": "680da8eb1d01505570bed1887f0f3952d5e2ec8345469d34872c9541ec0600e8", "order_number": "1234-234", "customer_name": "John Smith", "status": "active", "purchased_at": "2011-03-11 10:36:51", "items": [ { "offer_id": "0a3f749808c168528ba01a911ea63ee99a1eee3a7a6787dbd2159ebb6f4d372b", "quantity": "3", "vouchers": [ { "id": "3cc77d348d873abe7355f026015295d5fc6baf6109d01c72fd1f9c1e95ed8a2c", "offer_id": "0a3f749808c168528ba01a911ea63ee99a1eee3a7a6787dbd2159ebb6f4d372b", "redemption_code": "576339", "status": "acquired", "acquired_at": "2011-03-11 10:36:51", "barcode": { "url": "...", "width": "...", "height": "..." }, "print_url": "..." }, { "id": "ae7a16ae25dfb2852341eb8232cb9b05426c5414cab65e637976efbc9048da67", "offer_id": "0a3f749808c168528ba01a911ea63ee99a1eee3a7a6787dbd2159ebb6f4d372b", "redemption_code": "089032", "status": "acquired", "acquired_at": "2011-03-11 10:36:51", "barcode": { "url": "...", "width": "...", "height": "..." }, "print_url": "..." },
} } Clip CouponPOST /offers/<offer_id>/clips curl -k -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your_api_key>" 'http://testapi.adility.com/distribution/beta/offers/<offer_id>/clips' -d '{ "clip": {} }' Request{ "clip": { }} ResponseHTTP/1.1 200 OK { "status": "OK", "clip": { "voucher": {
} } Cancel OrderSometimes you need to cancel an order. You can do it by setting the order status to cancelled. { "order": { "status": "cancelled" } } After the order cancellation all vouchers purchased within this order are marked as cancelled as well. See order canceling examples at Order resource page. Cancel Voucher{ "voucher": { "status": "cancelled" } } You can cancel a single voucher. PUT /offers/<offer_id>/vouchers/<voucher_id> curl -k -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your_api_key>" 'http://testapi.adility.com/distribution/beta/offers/<offer_id>/vouchers/<voucher_id>' -d '{ "voucher": { "status": "cancelled" } }' Advanced CasesAside to the basic flow of Distribution API Adility supports a number of advanced features.
Manage AccountsIf you host customer facing applications for publishers you may need accounts in order to assign reservations and orders to a specific publisher on your end.Create AccountPOST /accounts { "account": { "name": "Spas Magazine", "website_url": "http://www.spas-magazine.com" } } { "status": "OK", "account": { "id": "680da8eb1d01505570bed1887f0f3952d5e2ec8345469d34872c9541ec0600e8", "name": "Spas Magazine", "website_url": "http://www.spas-magazine.com", "status": "pending" } } You can not assign any objects to the account until it is activated. Update AccountYou can change the account attributesname and website_url . Also, you can cancel an account by setting the status to cancelled.{ "account": { "status": "cancelled" } } Delete AccountAccount can be deleted if there is no object assigned to it. Otherwise you will get an error. DELETE /accounts/<account_id> Manage ReservationsOffers mostly are shared between distributors and there is no guarantee that the offer that you have chosen and scheduled for tomorrow is actually gonna be available tomorrow. It may just be sold out. Reservation is designed to help you protect yourself from missing offers. You reserve a certain number of vouchers by creating Reservation and they are no more available for others. By default reservations are disabled for distributors. If you think you want to use this feature send us a request to api@adility.com. Create ReservationPOST /offers/<offer_id>/reservations You should take into account following restrictions:
You can read about maximum_reservation_quantity in User. Request { "reservation": { "offer_id": "...", "quantity_reserved": "100", "start_date": "2011-03-13", "end_date": "2011-0319" } } Reservation can not be made for a period of time longer then 7 days. Also, start_date can't be more then 7 days from creation_date .Response { "status": "OK" "reservation": { "id": "15f479054487b5297e3b1a1288ced592a4c4eba913b4ef3b8c2765533c1ef5c4", "offer_id": "...", "quantity_reserved": "100",
"end_date": "2011-03-19", "creation_date": "2011-03-12", "status": "active" } } Update ReservationYou can update start_date , end_date and quantity_reserved . All restrictions above are applicable. Use Reservation in OrdersIf you want to use a reservation for a specific order you should set reservation_id for the corresponding order item.{ "order": { "items": [ { ... "reservation_id": " 15f479054487b5297e3b1a1288ced592a4c4eba913b4ef3b8c2765533c1ef5c4" } ] } } Delete ReservationReservation can be deleted only if it was not used for any order. DELETE /reservations/<reservation_id> Manage PromotionsIf you sell more then 50 vouchers a day per offer and you have a kind of schedule for offers in your application you will be obliged to create Promotion each time you feature an offer. This requirement comes from advertiser operations as advertisers need time to get prepared for customers you might bring to them. Create PromotionPOST /promotions reservation_id and account_id if you have them.{ "promotion": { "offer_id": "0a3f749808c168528ba01a911ea63ee99a1eee3a7a6787dbd2159ebb6f4d372b", "start_date": "2011-03-16", "end_date": "2011-03-18", "reservation_id": " 15f479054487b5297e3b1a1288ced592a4c4eba913b4ef3b8c2765533c1ef5c4", "account_id": "680da8eb1d01505570bed1887f0f3952d5e2ec8345469d34872c9541ec0600e8" } } { "promotion": { "id": "w8e6r8sd6f86wer86986gw8e6f98w6fd9g8gw68g6f88wgr6we9r8768w76r592e", "start_date": "2011-03-17", "end_date": "2011-03-19" } } Delete PromotionDELETE /promotions/<promotion_id> Selling Instant OffersYou can build an application set to promote instant offers to consumers. Instant offers can be shown to consumers and acquired by them only within a certain time frame along the day. For example, an advertiser can provide a great discount at morning hours when the foot trafic is low. Instant offers is a good fit for mobile geo applications.If you want to query only instant offers you should set the query parameter instant_offers to true. If you set this parameter to false instant offers won't be included in the result set. If the instant_offers parameter is not used in the query the result set contains all offers regardless if they are instant or not.Instant offers have restrictions defined by time_frames attribute of offer restrictions.{ "offer": { "restrictions": { "time_frames": [ { "week_day": "Mon" "from": "10AM" "to": "11AM" }, { "from": "4:30PM" "to": "6:00PM" } ] } } } Selling Bundle DealsThis type of offers is suppose to entice customers to come to advertiser location more then once. From consumers prospective bundle deals have a few coupons with different discounts. These coupons are presented by BundleItem resource and listed asitems attribute of the offer. The main difference in placing orders for bundle deals is that you get more then one voucher for an offer. For example, there's a bundle deal with 3 bundle items in it. When you place an order with quantity 2 for this offer you get 6 vouchers in the response which is 2x3. Checkin CouponsOffers of this type entice customers to return to advertiser location. Customer obtains a checkin coupon only after he checks in at a location a few times. The number of times required to get a checkin coupon is set by the checkins_required attribute of an offer.Check In at a LocationWhen a customer is at the advertiser location he can check in in your application and your application creates a checkin in Adility. POST /offers/<offer_id>/checkins You need to pass lat /lng attributes of the current customer location as well as customer_id uniquely identifying the customer in your system.{ "checkin": { "offer_id": "...", "location": { "lat": "", "lng": "" }, "customer_id": "3423437" } } checkins_remained attribute in the response. If it equals to 0 you can clip the coupon and provides a voucher to the customer.{ "status": "OK", "checkin": { "offer_id": "...", "location": { "lat": "", "lng": "" }, "customer_id": "3423437", "registered_at": "2011-03-11 11:03:29", "checkins_remained": "0" } } Clip a Checkin CouponIf the checkins_remained of the checkin equals to 0 you can clip the coupon for the customer.{ "clip": { "customer_id": " 3423437" } } After the coupon is clipped checkins counter for the customer is set back to checkins_required of the offer. |