• 商品を買う
  • 商品を売る
  • Ask
  • ブログ1
  • マイアカウント
  • € - EUR
    通貨...
    EUR - €
    USD - $
    JPY - 円
    GBP - £
    CAD - C$
    もっと見る ...
  • アカウントの作成
  • マイアカウント
検索フィールドを1つ選んでください:  お探しのフォーマットを1つ選んでください: 
0 カート



API CDandLP (Version 3.0)


1 - API to manage your orders
1.1 - What is it?
CDandLP’s API is a « Web Service » Application.

It will enable you to manage all your orders on CDandLP.com from an external agent/server.
1.2 - How to signup?
You must have a seller’s account on CDandLP.com.

You will have to supply CDandLP.com with the URL and/or the IP address of the server which will access our API.

In return, CDandLP.com will provide you with a unique user identification number that you will have to forward for every attempt to request the API.
1.3 - How to use it?
CDandLP’s API must be accessed with HTTPS.

Important :
- To communicate with the application you will have to use JSON files.
- The JSON table contains all the information regarding identification as well as the information regarding data you wish to get.
- It must be posted to the application into a variable with the name « json_object » (see example in the appendix).
- Data must be forwarded with POST or GET method
1.4 - Identification
When you want to call up CDandLP’s API, your JSON file must contain your User Identification number.

Example:
{
    "information":
    {
        "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
        .....
    }
}
1.5 - URL for the API on orders
The API for the management of your orders is accessible from the following URL:

https://api.cdandlp.com/orders/
1.6 - SandBox for the API on orders
You can carry out tests from the following URL:

https://apisandbox.cdandlp.com/orders/

Orders research is only available on your existing orders.

Changes won’t be applied on your existing orders’ confirmations, shipping confirmations and refunds.
The test version of the API on orders will only check your requests and send you a result as if the action had been effective. In case of an error in your request, the API will forward you the error statement.
1.7 - How to get orders according to status
1.7.1. Request

Your request with JSON file must contain the following data:

InformationUIDUser Identification Number
ACTIONALLORDERS
STATUS{0,1,2,3,4,5,-1}


Meanings of the different statuses available:


Status CodesMeaning of the codes
0New orders
1Orders awaiting for cashing
2Orders to ship
3Orders in transit (not received)
4Orders received
5Orders cancelled
-1All Orders


Example of the table to send in order to get all your new orders:

{
    "information":
    {
        "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
        "action": "ALLORDERS",
        "status": "0"
    }
}



1.7.1. Reply

CDandLP’s API replies with a JSON table containing the following information:

A first part displays the information sent by the client, as well as the parameter « success » which indicates whether the request was successful (OK) or if it generated an error « NOK ». For every « NOK » reply, a second parameter named « error » displays the reasons for it.

{
    "information":
    {
        "action": "ALLORDERS",
        "status": "0",
        "success": "OK"
    }
}


A second part displays all orders meeting the criteria requested by the client.

{
"orders":
    {
    "1":
    {
        "order_number":577248,
        "seller_order_number":12069,
        "order_date":"2012/10/08 10:58:04",
        "order_amount_items":24.60,
        "order_amount_discount":0.0,
        "order_amount_shipping":4.0,
        "order_amount":28.60,
        "order_currency":"EUR",
        "status":0,
        "items":
         {
            "1":
            {
             "description":"MASAKI BATOH - BRAIN PULSE MUSIC - LP - S\/S",
             "quantity":1,
             "reference_id":1065813403,
             "your_reference_id":"264455",
             "unit_price":5.75
            },
            "2":
            {
             "description":"Floetry - Say yes Remix - 12 inch x 1 - VG++/VG++",
             "quantity":1,
             "reference_id":104654165,
             "your_reference_id":"264493",
             "unit_price":18.85
            },
            "3":
            {
             .....
            },
             .....
        },
        "shipping_method":"Economy",
        "user_comment":"",
        "user_phone_number":"0000000000",
        "user_name":"magic33",
        "user_id":59776,
        "shipping_firstname":"cdandlp",
        "shipping_lastname":"cdandlp",
        "shipping_address":"private",
        "shipping_zip":"42000",
        "shipping_city":"private",
        "shipping_state":"",
        "shipping_country":"France",
        "billing_firstname":"cdandlp",
        "billing_lastname":"cdandlp",
        "billing_address":"private",
        "billing_zip":"42000",
        "billing_city":"private",
        "billing_state":"",
        "billing_country":"France"
    },
    "2":
    {
        .....
    },
    ....
    }
}

1.8 - How to get a specific order
1.8.1. Request

Your request with JSON file must contain the following data:

InformationUIDUser Identification Number
ACTIONORDER
ORDER_NUMBER000000

“Order_number” is CDandLP’s order number.

Example of the table to send in order to get all your new orders:

{
    "information":
    {
        "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
        "action": "ORDER",
        "order_number": "577248"
    }
}



1.8.1. Reply

CDandLP’s API replies with a JSON table containing the following information:

A first part displays the information sent by the client, as well as the parameter « success » which indicates whether the request was successful (OK) or if it generated an error « NOK ». For every « NOK » reply, a second parameter named « error » displays the reasons for it.

{
    "information":
    {
        "action": "ORDER",
        "order_number": "577248",
        "success": "OK"
    }
}


A second part displays all orders meeting the criteria requested by the client.

{
"orders":
    {
     "1":
        {
         "order_number":577248,
         "seller_order_number":12069,
         "order_date":"2012/10/08 10:58:04",
         "order_amount_items":24.60,
         "order_amount_discount":0.0,
         "order_amount_shipping":4.0,
         "order_amount":28.60,
         "order_currency":"EUR",
         "status":0,
         "items":
             {
                "1":
                {
                 "description":"MASAKI BATOH - BRAIN PULSE MUSIC - LP - S\/S",
                 "quantity":1,
                 "reference_id":1065813403,
                 "your_reference_id":"264455",
                 "unit_price":5.75
                },
                "2":
                {
                 "description":"Floetry - Say yes Remix - 12 inch x 1 - VG++/VG++",
                 "quantity":1,
                 "reference_id":104654165,
                 "your_reference_id":"264493",
                 "unit_price":18.85
                }
         },
         "shipping_method":"Economy",
         "user_comment":"",
         "user_phone_number":"0000000000",
         "user_name":"magic33",
         "user_id":59776,
         "shipping_firstname":"cdandlp",
         "shipping_lastname":"cdandlp",
         "shipping_address":"private",
         "shipping_zip":"42000",
         "shipping_city":"private",
         "shipping_state":"",
         "shipping_country":"France",
         "billing_firstname":"cdandlp",
         "billing_lastname":"cdandlp",
         "billing_address":"private",
         "billing_zip":"42000",
         "billing_city":"private",
         "billing_state":"",
         "billing_country":"France"
        }
    }
}

1.9 - How to confirm a new order
1.9.1. Request

Your request with JSON file must contain the following data:


InformationUIDUser Identification Number
ACTIONORDER
ORDER_NUMBER000000
ORDER_AMOUNT_SHIPPING0.0 (Optional, empty by default)
ORDER_AMOUNT_DISCOUNT0.0 (Optional, empty by default)
ITEMSJSON Table


ItemsREFERENCE_ID
AND/OR
YOUR_REFERENCE_ID
000000000 (CDandLP ID number)
AND/OR
000000000 (Your Ref ID)
QUANTITY1 (Mandatory)


- “Order_number” is CDandLP’s order number.

- Order_amount_shipping and order_amount_discount are NOT mandatory data.

- Order_amount_shipping enables to reduce shipping fees; for instance, if one item is sold out.

- Order_amount_discount enables to discount the order.

- With regard to items, you can either state cdandlp’s ID Number or the Ref ID you used when you listed your inventory on CDandLP database.

- Quantity: If you state « 0 », the item will show « sold out ». If all the items of an order state a quantity of « 0 », the order will be cancelled.


Example of the table to send in order to get all your new orders:

{
     "information":
     {
         "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
         "action": "CONFIRM_ORDER",
         "order_number": "577248",
         "items":
             {
                "1":
                {
                 "quantity":1,
                 "reference_id":1065813403,
                 "your_reference_id":264455
                },
                "2":
                {
                 "quantity":0,
                 "reference_id":104654165,
                 "your_reference_id":264493
                }
         }
     }
}



1.9.2. Reply

CDandLP’s API replies with a JSON table containing the following information:

A first part displays the information sent by the client, as well as the parameter « success » which indicates whether the request was successful (OK) or if it generated an error « NOK ». For every « NOK » reply, a second parameter named « error » displays the reasons for it.

{
     "information":
     {
         "action": "CONFIRM_ORDER",
         "order_number": "577248",
         "success": "OK"
     }
}


Possible errors for the action « CONFIRM_ORDER »:

Order does not existNo such order number could be found.
Order already confirmedThe availabilities of this order have already been confirmed.
Quantity of items are not correspondingThe number of items forwarded by the client and the one contained in CDandLP database do not match for this order.
Your reference id does not existOne of the references forwarded by the client doesn’t match any item from CDandLP database for this order.
Reference id does not existOne of the CDandLP reference number forwarded by the client doesn’t match any item from CDandLP database for this order.
Reference id and your reference id does not existNone of the 2 references forwarded by the client match any item from CDandLP database for this order.
Shipping amount is not correctThe shipping amount is superior to ours, the format is invalid...
Discount amount is not correctThe amount of the discount is superior to the order’s amount, the format is invalid...
Quantity confirmed should be less than quantity orderedThe forwarded quantity mustn’t exceed the initial quantity ordered by the buyer.


A second part contains the detail of the order following the action requested by the client.

Please note: Order status changes from 0 to 1. Order amounts are also updated.

{
"orders":
{
     "1":
        {
         "order_number":577248,
         "seller_order_number":12069,
         "order_date":"2012/10/08 10:58:04",
         "order_amount_items":5.75,
         "order_amount_discount":0.0,
         "order_amount_shipping":4.0,
         "order_amount":9.75,
         "order_currency":"EUR",
         "status":1,
         "items":
             {
                "1":
                {
                 "description":"MASAKI BATOH - BRAIN PULSE MUSIC - LP - S\/S",
                 "quantity":1,
                 "reference_id":1065813403,
                 "your_reference_id":"264455",
                 "unit_price":5.75
                },
                "2":
                {
                 "description":"Floetry - Say yes Remix - 12 inch x 1 - VG++/VG++",
                 "quantity":0,
                 "reference_id":104654165,
                 "your_reference_id":"264493",
                 "unit_price":0.0
                }
         },
         "shipping_method":"Economy",
         "user_comment":"",
         "user_phone_number":"0000000000",
         "user_name":"magic33",
         "user_id":59776,
         "shipping_firstname":"cdandlp",
         "shipping_lastname":"cdandlp",
         "shipping_address":"private",
         "shipping_zip":"42000",
         "shipping_city":"private",
         "shipping_state":"",
         "shipping_country":"France",
         "billing_firstname":"cdandlp",
         "billing_lastname":"cdandlp",
         "billing_address":"private",
         "billing_zip":"42000",
         "billing_city":"private",
         "billing_state":"",
         "billing_country":"France"
        }
    }
}

1.10 - How to confirm the shipment of an order
1.10.1. Request

Your request with JSON file must contain the following data:


InformationUIDUser Identification Number
ACTIONSHIP_ORDER
ORDER_NUMBER000000
SHIPMENT_DATEyyyy/mm/dd (optional, current date by default)
URL_DELIVERY_COMPANYhttp://www.ups.com (optional, max 255)
TRACKING_NUMBERUPS4546465 (optional, max 30)


- “Order_number” is CDandLP’s order number.

- Shipment_date: Corresponds to the order’s shipping date; when no date is forwarded, CDandLP will use the current date as the order’s shipping date.

- Url_delivery_company: Corresponds to the link towards the website buyers can use to track and trace their orders.

- Tracking_number: Corresponds to the tracking number provided by the transport carrier.

Example of the table to send in order to confirm the shipment of an order:

{
     "information":
     {
         "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
         "action": "SHIP_ORDER",
         "order_number": "577248",
         "shipment_date": "2012/10/08",
         "url_delivery_company : "http://www.ups.com",
         "tracking_number" : "UPS4546465"
     }
}



1.10.2. Reply

CDandLP’s API replies with a JSON table containing the following information:

A first part displays the information sent by the client, as well as the parameter « success » which indicates whether the request was successful (OK) or if it generated an error « NOK ». For every « NOK » reply, a second parameter named « error » displays the reasons for it.

{
     "information":
     {
         "action": "SHIP_ORDER",
         "order_number": "577248",
         "success": "OK"
     }
}


Possible errors for the action « SHIP_ORDER »:

Order does not existNo such order number could be found.
Order already shippedThe shipment of this order has already been confirmed.
Orders waiting for cashingThe order cannot be shipped. It has not been cashed yet.


A second part contains the detail of the order following the action requested by the client.

Please note: The order status changes to 3.

{
"orders":
{
    "1":
     {
        "order_number":577248,
        "seller_order_number":12069,
        "order_date":"2012/10/08 10:58:04",
        "order_amount_items":5.75,
        "order_amount_discount":0.0,
        "order_amount_shipping":4.0,
        "order_amount":9.75,
        "order_currency":"EUR",
        "status":3,
        "items":
         {
            "1":
            {
             "description":"MASAKI BATOH - BRAIN PULSE MUSIC - LP - S\/S",
             "quantity":1,
             "reference_id":1065813403,
             "your_reference_id":"264455",
             "unit_price":5.75
            },
            "2":
            {
             "description":"Floetry - Say yes Remix - 12 inch x 1 - VG++/VG++",
             "quantity":0,
             "reference_id":104654165,
             "your_reference_id":"264493",
             "unit_price":0.0
            }
        },
        "shipping_method":"Economy",
        "user_comment":"",
        "user_phone_number":"0000000000",
        "user_name":"magic33",
        "user_id":59776,
        "shipping_firstname":"cdandlp",
        "shipping_lastname":"cdandlp",
        "shipping_address":"private",
        "shipping_zip":"42000",
        "shipping_city":"private",
        "shipping_state":"",
        "shipping_country":"France",
        "billing_firstname":"cdandlp",
        "billing_lastname":"cdandlp",
        "billing_address":"private",
        "billing_zip":"42000",
        "billing_city":"private",
        "billing_state":"",
        "billing_country":"France"
     }
}
}

1.11 - How to ask for a partial refund
1.11.1. Request

Your request with JSON file must contain the following data:

InformationUIDUser Identification Number
ACTIONASK_PARTIAL_REFUND_ORDER
ORDER_NUMBER000000
AMOUNT_REFUND0.0


- “Order_number” is CDandLP’s order number.

- Amount_refund : Corresponds to the amount that you wish to refund to your buyer.

Remember, if you wish to refund a complete order, you must use the action « ASK_COMPLETE_REFUND_ORDER ».

Example of the table to send in order to ask for a partial refund:

{
{
    "information":
    {
        "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
        "action": "ASK_PARTIAL_REFUND_ORDER",
        "order_number": "577248",
        "amount_refund ": "4.0"
    }
}



1.11.2. Reply

CDandLP’s API replies with a JSON table containing the following information:

A first part displays the information sent by the client, as well as the parameter « success » which indicates whether the request was successful (OK) or if it generated an error « NOK ». For every « NOK » reply, a second parameter named « error » displays the reasons for it.

{
    "information":
    {
        "action": " ASK_PARTIAL_REFUND_ORDER",
        "order_number": "577248",
        "success": "OK"
    }
}


Possible errors for the action « ASK_PARTIAL_REFUND_ORDER »:

Order does not existNo such order number could be found.
Orders waiting for cashingNo refund can be requested. The order has not been cashed yet.
Refund already askedA request for a partial refund is already pending.


A second part contains the detail of the order following the action requested by the client.

{
"orders":
{
    "1":
     {
        "order_number":577248,
        "seller_order_number":12069,
        "order_date":"2012/10/08 10:58:04",
        "order_amount_items":5.75,
        "order_amount_discount":0.0,
        "order_amount_shipping":4.0,
        "order_amount":9.75,
        "order_currency":"EUR",
        "status":3,
        "items":
         {
            "1":
            {
             "description":"MASAKI BATOH - BRAIN PULSE MUSIC - LP - S\/S",
             "quantity":1,
             "reference_id":1065813403,
             "your_reference_id":"264455",
             "unit_price":5.75
            },
            "2":
            {
             "description":"Floetry - Say yes Remix - 12 inch x 1 - VG++/VG++",
             "quantity":0,
             "reference_id":104654165,
             "your_reference_id":"264493",
             "unit_price":0.0
            }
        },
        "shipping_method":"Economy",
        "user_comment":"",
        "user_phone_number":"0000000000",
        "user_name":"magic33",
        "user_id":59776,
        "shipping_firstname":"cdandlp",
        "shipping_lastname":"cdandlp",
        "shipping_address":"private",
        "shipping_zip":"42000",
        "shipping_city":"private",
        "shipping_state":"",
        "shipping_country":"France",
        "billing_firstname":"cdandlp",
        "billing_lastname":"cdandlp",
        "billing_address":"private",
        "billing_zip":"42000",
        "billing_city":"private",
        "billing_state":"",
        "billing_country":"France"
     }
}
}

1.12 - How to ask for a complete refund
1.12.1. Request

Your request with JSON file must contain the following data:

InformationUIDUser Identification Number
ACTIONASK_COMPLETE_REFUND_ORDER
ORDER_NUMBER000000


- “Order_number” is CDandLP’s order number.

Please note: You don’t need to forward any amount. A full refund of the order will be processed.

Example of the table to send in order to ask for a complete refund:

{
    "information":
    {
        "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
        "action": "ASK_COMPLETE_REFUND_ORDER",
        "order_number": "577248"
    }
}



1.12.2. Reply

CDandLP’s API replies with a JSON table containing the following information:

A first part displays the information sent by the client, as well as the parameter « success » which indicates whether the request was successful (OK) or if it generated an error « NOK ». For every « NOK » reply, a second parameter named « error » displays the reasons for it.

{
    "information":
    {
        "action": " ASK_COMPLETE_REFUND_ORDER",
        "order_number": "577248",
        "success": "OK"
    }
}


Possible errors for the action « ASK_COMPLETE_REFUND_ORDER »:

Order does not existNo such order number could be found.
Orders waiting for cashingNo refund can be requested. The order has not been cashed yet.
Refund already askedA request for a refund is already pending


A second part contains the detail of the order following the action requested by the client.

{
"orders":
{
    "1":
     {
        "order_number":577248,
        "seller_order_number":12069,
        "order_date":"2012/10/08 10:58:04",
        "order_amount_items":5.75,
        "order_amount_discount":0.0,
        "order_amount_shipping":4.0,
        "order_amount":9.75,
        "order_currency":"EUR",
        "status":3,
        "items":
         {
            "1":
            {
             "description":"MASAKI BATOH - BRAIN PULSE MUSIC - LP - S\/S",
             "quantity":1,
             "reference_id":1065813403,
             "your_reference_id":"264455",
             "unit_price":5.75
            },
            "2":
            {
             "description":"Floetry - Say yes Remix - 12 inch x 1 - VG++/VG++",
             "quantity":0,
             "reference_id":104654165,
             "your_reference_id":"264493",
             "unit_price":0.0
            }
        },
        "shipping_method":"Economy",
        "user_comment":"",
        "user_phone_number":"0000000000",
        "user_name":"magic33",
        "user_id":59776,
        "shipping_firstname":"cdandlp",
        "shipping_lastname":"cdandlp",
        "shipping_address":"private",
        "shipping_zip":"42000",
        "shipping_city":"private",
        "shipping_state":"",
        "shipping_country":"France",
        "billing_firstname":"cdandlp",
        "billing_lastname":"cdandlp",
        "billing_address":"private",
        "billing_zip":"42000",
        "billing_city":"private",
        "billing_state":"",
        "billing_country":"France"
     }
}
}

1.13 - Example of a client program using JQUERY library

<!DOCTYPE html>
<html>
<head>
<title>Posting JSON Data To The API ORDER Using jQuery</title>
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

<script>

$(document).ready(function() {

    var json_request = { information : { uid: "854f2cbc6e53d2781a58e46bce2b0f24", action: "ALLORDERS", status: "1" }};
    
    $("#jsonbutton").click(function() {
        var surl = "https://apisandbox.cdandlp.com/orders/";
        $.ajax({
            type: "POST",
            url: surl,
            data: 'json_object='+JSON.stringify(json_request),
            dataType: "jsonp",
            contentType: "application/json",
            jsonp : "callback",
            jsonpCallback: "jsonpcallback",
            error : function (){$('#response').html('nok')}
                 });
    });
});
    
// Named callback function from the ajax call when jsonbutton clicked
function jsonpcallback(data) {
    // Get the success information from the returned JSON string
    if (data.information.success == 'ok')
    {
        $('#response').html(data.information.success);
    }
    else
    {
        $('#response').html(data.information.error);
    }
}

</script>


<input type="button" id="jsonbutton" value="GET ORDERS TO CONFIRM">

<div id="response">
</div>

</body>

2 - API to manage your items
2.1 - What is it?
CDandLP’s API is a « Web Service » Application.

It will enable you to manage all your items on CDandLP.com from an external agent/server.
For the moment, only delete items action is available. You can not insert and update items.

2.2 - How to signup?
You must have a seller’s account on CDandLP.com.

You will have to supply CDandLP.com with the URL and/or the IP address of the server which will access our API.

In return, CDandLP.com will provide you with a unique user identification number that you will have to forward for every attempt to request the API.
2.3 - How to use it?
CDandLP’s API must be accessed with HTTPS.

Important :
- To communicate with the application you will have to use JSON files.
- The JSON table contains all the information regarding identification as well as the information regarding data you wish to get.
- It must be posted to the application into a variable with the name « json_object » (see example in the appendix).
- Data must be forwarded with POST or GET method
2.4 - Identification
When you want to call up CDandLP’s API, your JSON file must contain your User Identification number.

Example:
{
    "information":
    {
        "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
        .....
    }
}
2.5 - URL for the API on items
The API for the management of your items is accessible from the following URL:

https://api.cdandlp.com/items/
2.6 - SandBox for the API on items
You can carry out tests from the following URL:

https://apisandbox.cdandlp.com/items/

items research is only available on your existing items.

Changes won’t be applied on your existing items.
The test version of the API on items will only check your requests and send you a result as if the action had been effective. In case of an error in your request, the API will forward you the error statement.
2.7 - How to delete an item
2.7.1. Request

Your request with JSON file must contain the following data:

InformationUIDUser Identification Number
ACTIONDELETE_ITEM
SKUStock Keeping Unit


“SKU” is the reference number of your item.

Example of the table to send in order to delete one specific item:

{
    "information":
    {
        "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
        "action": "DELETE_ITEM",
        "sku": "94932232095"
    }
}



2.7.2. Reply

CDandLP’s API replies with a JSON table containing the following information:

A first part displays the information sent by the client, as well as the parameter « success » which indicates whether the request was successful (OK) or if it generated an error « NOK ». For every « NOK » reply, a second parameter named « error » displays the reasons for it.

{
    "information":
    {
        "action": "DELETE_ITEM",
        "sku": "94932232095",
        "success": "OK"
    }
}


Possible errors for the action « DELETE_ITEM »:

Item does not existNo such item could be found.
SKU is not uniqueSeveral items have the same SKU


2.8 - Example of a client program using JQUERY library

<!DOCTYPE html>
<html>
<head>
<title>Posting JSON Data To The API ITEMS Using jQuery</title>
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

<script>

$(document).ready(function() {

    var json_request = { information : { uid: "854f2cbc6e53d2781a58e46bce2b0f24", action: "DELETE", sku: "94932232095" }};
    
    $("#jsonbutton").click(function() {
        var surl = "https://apisandbox.cdandlp.com/items/";
        $.ajax({
            type: "POST",
            url: surl,
            data: 'json_object='+JSON.stringify(json_request),
            dataType: "jsonp",
            contentType: "application/json",
            jsonp : "callback",
            jsonpCallback: "jsonpcallback",
            error : function (){$('#response').html('nok')}
                 });
    });
});
    
// Named callback function from the ajax call when jsonbutton clicked
function jsonpcallback(data) {
    // Get the success information from the returned JSON string
    if (data.information.success == 'ok')
    {
        $('#response').html(data.information.success);
    }
    else
    {
        $('#response').html(data.information.error);
    }
}

</script>


<input type="button" id="jsonbutton" value="DELETE ITEM">

<div id="response">
</div>

</body>

3 - API to launch a research in the database
3.1 - What is it?
CDandLP’s API is a « Web Service » Application.

It will enable you to search items on CDandLP.com marketplace from an external agent/server.
3.2 - How to signup?
You must have an account on CDandLP.com.

You will have to supply CDandLP.com with the URL and/or the IP address of the server which will access our API.

In return, CDandLP.com will provide you with a unique user identification number that you will have to forward for every attempt to request the API.
3.3 - How to use it?
CDandLP’s API must be accessed with HTTPS.

Important :
- To communicate with the application you will have to use JSON files.
- The JSON table contains all the information regarding identification as well as the information regarding data you wish to get.
- It must be posted to the application into a variable with the name « json_object » (see example in the appendix).
- Data must be forwarded with POST or GET method
3.4 - Identification
When you want to call up CDandLP’s API, your JSON file must contain your User Identification number.

Example:
{
    "information":
    {
        "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
        .....
    }
}
3.5 - URL to use for the searching API
The API for launching an item research is accessible from the following URL:

https://api.cdandlp.com/search/
3.6 - How to launch a research
3.6.1. Request

Your request with JSON file must contain the following data:


InformationUIDUser Identification Number
ACTIONSEARCH
LNG{fr,en,ja,es,de} (Optional, default value : en)
ARTISTOptionalOne of the four mandatory values
TITLEOptional
LABELOptional
SELLERSeller name (Optional)
ALLFIELDS(Optional) Search directly into the following fields: ARTIST, TITLE, LABEL, SELLER
MEDIACODE (Optional, All medias if empty)
PICTUREYES, NO (If YES, provides items with picture only. Default value: NO)
NB_ITEMSDefault value : 20
SRT{1,2,3,4,5,6,7,8,9} Default value: 6


Meanings of the different medias available:

MEDIACode :Returns media :
ALBUMLP + CD ALBUM
VINYLLP + 7 INCH + MAXI + 78 RPM + 10 INCH
LPLP + LPx2 + LPx3 + ... + LP BOX
77” + 7”x2+ 7”x3 + ... + 7” BOX
1212” 45rpm + 12” 33rpm + x2 + x3 + ... + BOX
7878RPM + x2 + x3 + … + BOX
1010” + 10”x2 + 10”x3 + ... + 10” BOX
CDCD ALBUM + CD SINGLE + CD MAXI
CDALBUMCD + CDx2 + CDx3 + ... + CD BOX
CDSINGLECD Single + CD Single x2 + ... + CD Single BOX
CDMAXICD Maxi + CD Maxi x2 + ... + CD Maxi BOX
VIDEODVD + VHS
DVDDVD + DVDx2 + ... + DVD BOX
VHSVHS + VHSx2 + ... + VHS BOX
TAPETAPE + TAPEx2 + TAPE BOX
MERCHCLOTHING + Drink Coaster + Sticker ...
CLOTHINGPANT + TSHIRT + SWEATSHIRT + ACCESSORIES


Meanings of the different available sorting methods:

SRTCode :Signification :
1Relevance
2Last inserted items
3Artist (A-Z), Titre (A-Z)
4Title (A-Z), Price (0-9)
5Media
6Price (0-9)
7Price (9-0)
8Artist (Z-A), Title (Z-A)
9Title (Z-A)


Example of the table to send in order to search in the database:

{
    "information":
    {
        "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
        "action": "SEARCH",
        "artist": "madonna",
        "title": "la isla bonita",
        "nb_items": "3"
    }
}



3.6.2. Reply

CDandLP’s API replies with a JSON table containing the following information:

A first part displays the information sent by the client, as well as the parameter « success » which indicates whether the request was successful (OK) or if it generated an error « NOK ». For every « NOK » reply, a second parameter named « error » displays the reasons for it.

{
    "information":
    {
        "uid": "854f2cbc6e53d2781a58e46bce2b0f24",
        "action": "SEARCH",
        "success": "OK",
        "nb_items": "3",
        "items":
         {
            "1":
            {
             "artist":”Madonna”,
             "title":”la isla bonita”,
             "label":”sire Records”
             "media":”7 inch (SP)”
             "general_grading":”used”,
             "grading_cover":”VG+”,
             "grading_media":”VG++”,
             "pressing":”france”,
             "year":”1987”,
             "price:”1.2”,
             "currency":”EUR”,
             "img_url_1":”http://ring.cdandlp.com/brando51/photo_grande/113406075.jpg”,
             "img_url_2":””,
             "img_url_3":””,
             "shop_url":”http://www.cdandlp.com/en/madonna/la-isla-bonita/7inch-sp/r113406075/?affilie=xxxxxx”,
             "seller_name":”brando51”
            },
            "2":
            {
             "artist":”Madonna”,
             "title":”la isla bonita (remix)”,
             "label":”Sire”
             "media":”7 inch”
             "general_grading":”used”,
             "grading_cover":”B”,
             "grading_media":”EX”,
             "pressing":”Germany – 928378-7”,
             "year":”1987”,
             "price:”2.64”,
             "currency":”EUR”,
             "img_url_1":”http://retro.recordsale.de/cdpix/m/madonna-laislabonita(remix).jpg”,
             "img_url_2":””,
             "img_url_3":””,
             "shop_url":”http://www.cdandlp.com/en/madonna/la-isla-bonita-remix/7inch/r3050759995/?affilie=xxxxxx”,
             "seller_name":”recordsale”
            },
            "3":
            {
             "artist":”Madonna”,
             "title":”la isla bonita ( remix ) / instrumental”,
             "label":”Sire”
             "media":”7 inch”
             "general_grading":”used”,
             "grading_cover":”VG+”,
             "grading_media":”VG+”,
             "pressing":”UK”,
             "year":”1987”,
             "price:”3.45”,
             "currency":”EUR”,
             "img_url_1":”http://ring.cdandlp.com/carlo/photo_grande/7177992.jpg”,
             "img_url_2":”http://ring.cdandlp.com/carlo/photo_grande/7177992-2.jpg”,
             "img_url_3":”http://ring.cdandlp.com/carlo/photo_grande/7177992-3.jpg”,
             "shop_url":”http://www.cdandlp.com/en/madonna/la-isla-bonita-remix-instrumental/7inch-sp/r7177992/?affilie=xxxxxx”,
             "seller_name":”carlo”
            }
        }
     }
}


Possible result values for the action « SEARCH »:

OKSearch return one or more items
NO ITEMSNo such item could be found
NOKOne or more mandatory parameters are missing

3.7 - Example of a client program using JQUERY library

<!DOCTYPE html>
<html>
<head>
<title>Posting JSON Data To The API SEARCH Using jQuery</title>
</head>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

<script>

$(document).ready(function() {

    $("#jsonbutton").click(function() {
        
        if ($("#search_picture").is(':checked'))
        {
            picture_value = "YES";
        }
        else
        {
            picture_value = "NO";
        }

        var json_request = { "information" : { "uid" : "8de565456z4d65z4dz654sza6klezjkl" , "action": "SEARCH" , "lng" : $("#search_lng").val(), "artist" : $("#search_artist").val(), "title" : $("#search_title").val(), "label" : $("#search_label").val(), "media" : $("#search_media").val(), "picture" : picture_value, "nb_items" : $("#search_nb_items").val(), "srt" : $("#search_srt").val(), "seller" : $("#search_seller").val()}};

     var surl = "http://api.cdandlp.com/search/";
     $.ajax({
         type: "POST",
     url: surl,
     data: 'json_object='+JSON.stringify(json_request),
     dataType: "jsonp",
     contentType: "application/json",
     jsonp : "callback",
     jsonpCallback: "jsonpcallback",
     error : function (){$('#response').html('nok')}
});
    });
});


// Named callback function from the ajax call when jsonbutton clicked
function jsonpcallback(data) {

    // Get the success information from the returned JSON string
    if (data.information.success == 'ok')
    {

        result = "Nb items : "+data.information.nb_items+"<br>";

        for (i = 1; i <= data.information.nb_items; i++) {
            result = result + "<img src='"+data.information.items[i]["img_url_1"]+"' style='width:65px;'> "
            +data.information.items[i]["artist"]+" "
            +data.information.items[i]["title"]+" - "
            +data.information.items[i]["label"]+" - ("
            +data.information.items[i]["media"]+") - "
            +data.information.items[i]["general_grading"]+" ("
            +data.information.items[i]["general_media"]+"/"
            +data.information.items[i]["general_cover"]+") - Price : "
            +data.information.items[i]["price"]+" "
            +data.information.items[i]["currency"]
            +" <a href='"+data.information.items[i]["shop_url"]+"' target='_blank'>BUY</a>"
            +"<br>";
        }

        $('#response').html(result);
        
    }
    else
    {
        $('#response').html(data.information.error);
    }
}


</script>

Artist : <input type="text" id="search_artist" value=""> - Title : <input type="text" id="search_title" value=""> - Label : <input type="text" id="search_label" value=""><br><br>
Seller : <input type="text" id="search_seller" value="">
<br><br>
Language : <select id="search_lng">
    <option value="fr">fr</option>
    <option value="en" selected="selected">en</option>
    <option value="ja">ja</option>
    <option value="es">es</option>
    <option value="de">de</option>
</select>
<br><br>
Media : <select id="search_media">
    <option value="" selected="selected">ALL</option>
    <option value="ALBUM">ALBUM (LP + CD ALBUM)</option>
    <option value="VINYL">VINYL (LP + 7 INCH + MAXI + 78 RPM + 10 INCH)</option>
    <option value="LP">LP (LP + LPx2 + LPx3 + ... + LP BOX)</option>
    <option value="7">7 inch (7” + 7”x2+ 7”x3 + ... + 7” BOX )</option>
    <option value="12">12 inch (12” 45rpm + 12” 33rpm + x2 + x3 + ... + BOX)</option>
    <option value="78">78 RPM (78RPM + x2 + x3 + … + BOX)</option>
    <option value="10">10 inch (10” + 10”x2 + 10”x3 + … + 10” BOX)</option>
    <option value="CD">ALL CD (CD ALBUM + CD SINGLE + CD MAXI)</option>
    <option value="CDALBUM">CD ALBUM (CD + CDx2 + CDx3 + … + CD BOX)</option>
    <option value="CDSINGLE">CD SINGLE (CD Single + CD Single x2 + ... + CD Single BOX)</option>
    <option value="CDMAXI">CD MAXI (CD Maxi + CD Maxi x2 + ... + CD Maxi BOX)</option>
    <option value="VIDEO">VIDEO (DVD + VHS)</option>
    <option value="DVD">DVD (DVD + DVDx2 + … + DVD BOX)</option>
    <option value="VHS">VHS (VHS + VHSx2 + … + VHS BOX)</option>
    <option value="TAPE">TAPE (TAPE + TAPEx2 + TAPE BOX)</option>
    <option value="MERCH">MERCH (CLOTHING + Drink Coaster + Sticker…)</option>
    <option value="CLOTHING">CLOTHING (PANT + TSHIRT + SWEATSHIRT + ACCESSORIES)</option>
</select>
<br><br>
<input type="checkbox" id="search_picture" value="YES" checked="checked"> Only items with pictures
<br><br>
Nb Items : <select id="search_nb_items">
    <option value="5">5</option>
    <option value="10">10</option>
    <option value="20" selected="selected">20</option>
    <option value="30">30</option>
    <option value="40">40</option>
    <option value="50">50</option>
    <option value="100">100</option>
    <option value="250">250</option>
</select>
<br><br>
Sort By : <select id="search_srt">
    <option value="1">Relevance</option>
    <option value="2">Last inserted items</option>
    <option value="3">Artiste (A-Z), Titre (A-Z)</option>
    <option value="4">Title (A-Z), Price (0-9)</option>
    <option value="5">Media</option>
    <option value="6" selected="selected">Price (0-9)</option>
    <option value="7">Price (9-0)</option>
    <option value="8">Artiste (Z-A), Title (Z-A)</option>
    <option value="9">Title (Z-A)</option>
</select>
<br><br>
<input type="button" id="jsonbutton" value="GET ITEMS">
<br><br>

<div id="response">
</div>

</body>