{"_id":"5881e96b529da83900fc3417","title":"REST API","excerpt":"","project":"5881e96b529da83900fc33e4","body":"## The payload data has to be RFC 3986 ([http://www.ietf.org/rfc/rfc3986.txt](http://www.ietf.org/rfc/rfc3986.txt)) url encoded and spaces will be percent encoded \"%20\". \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Client libraries\"\n}\n[/block]\nAt the moment there is only one client library available in PHP.\n[https://github.com/concardis/paylink](https://github.com/concardis/paylink)\n\nThe corresponding examples you can find in the Github Repository as well:\n[https://github.com/concardis/paylink/tree/master/examples]https://github.com/concardis/paylink/tree/master/examples)\n\nIf you are programming in another language, no problem, our API is accessible with a normal HTTP request.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Request\"\n}\n[/block]\nThe basic URL to our API is: https://api.pay-link.eu/v1.0/:object/:id?instance=:instance\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Value\",\n    \"0-0\": \"object\",\n    \"0-1\": \"AuthToken | Invoice | Page | Subscription\",\n    \"1-0\": \"id\",\n    \"1-1\": \"Only used for request types GET, PUT and DELETE where only one entity gets modified.\",\n    \"2-0\": \"instance\",\n    \"2-1\": \"The Paylink instance name.\\nIf you access your Paylink payment page with example.pay-link.eu, the name would be **example**\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Signature (rfc2104)\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Is this important for you?\",\n  \"body\": \"This part of the documentation is only important if you are not using a client library. Our client libraries are built to handle this signature automatically.\"\n}\n[/block]\nFor security reasons we want you to pass an API Signature calculated with the API Secret of your instance.\nThe parameter name of this API Signature should be **ApiSignature**. You can calculate the signature using all params except the param **instance**.\n* Build query string (e.g. model=Page&id=17)\n* Calculate binary hmac hash using your instance's API Secret as key\n* Encode it with base64\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"base64_encode(hash_hmac('sha256', http_build_query($params, null, '&'), $apiSecret, true));\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"echo -n \\\"HTTP-QUERY-STRING\\\" | openssl dgst -sha256 -hmac \\\"API-SECRET\\\" -binary | openssl enc -base64\",\n      \"language\": \"shell\"\n    },\n    {\n      \"code\": \"import urllib.request\\nimport hmac\\nimport hashlib\\nimport base64\\n\\npost_data = {}\\n\\nhttpQueryString = urllib.parse.urlencode(post_data).encode('UTF-8')\\n\\napiSignature = hmac.new(b'API-SECRET', msg=httpQueryString, digestmod=hashlib.sha256).digest()\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"The query string has to be RFC 1738 ([https://www.ietf.org/rfc/rfc1738.txt](https://www.ietf.org/rfc/rfc1738.txt)) encoded, that means you have to replace spaces by \\\"+\\\".\\nYou can probably use: [http://linux.die.net/man/1/urlencode](http://linux.die.net/man/1/urlencode)\",\n  \"title\": \"Encoding of HTTP-Query String\"\n}\n[/block]","hidden":false,"link_url":"","githubsync":"","isReference":true,"link_external":false,"order":0,"slug":"rest-api","api":{"auth":"required","params":[{"ref":"","in":"path","required":true,"desc":"This is the name of the object to handle","default":"","type":"string","name":"object","_id":"559fe3a2a195040d002921dc"},{"default":"0","type":"int","name":"id","_id":"559fe3a2a195040d002921db","ref":"","in":"path","required":false,"desc":"The object's identifier for data manipulation"},{"in":"path","required":false,"desc":"The name of your Payrexx instance","default":"","type":"string","name":"instance","_id":"559fe3a2a195040d002921da","ref":""}],"url":"/:object/:id/?instance=:instance","examples":{"codes":[{"language":"text","code":""}]},"results":{"codes":[{"language":"text","code":""}]},"settings":""},"category":"5881e96b529da83900fc33e7","createdAt":"2015-07-10T15:24:18.505Z","version":"5881e96b529da83900fc33e5","sync_unique":"","type":"basic","user":"559faf09a195040d00292112","updates":[],"__v":0,"next":{"pages":[],"description":""},"parentDoc":null,"childrenPages":[]}
## The payload data has to be RFC 3986 ([http://www.ietf.org/rfc/rfc3986.txt](http://www.ietf.org/rfc/rfc3986.txt)) url encoded and spaces will be percent encoded "%20". [block:api-header] { "type": "basic", "title": "Client libraries" } [/block] At the moment there is only one client library available in PHP. [https://github.com/concardis/paylink](https://github.com/concardis/paylink) The corresponding examples you can find in the Github Repository as well: [https://github.com/concardis/paylink/tree/master/examples]https://github.com/concardis/paylink/tree/master/examples) If you are programming in another language, no problem, our API is accessible with a normal HTTP request. [block:api-header] { "type": "basic", "title": "Request" } [/block] The basic URL to our API is: https://api.pay-link.eu/v1.0/:object/:id?instance=:instance [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Value", "0-0": "object", "0-1": "AuthToken | Invoice | Page | Subscription", "1-0": "id", "1-1": "Only used for request types GET, PUT and DELETE where only one entity gets modified.", "2-0": "instance", "2-1": "The Paylink instance name.\nIf you access your Paylink payment page with example.pay-link.eu, the name would be **example**" }, "cols": 2, "rows": 3 } [/block] [block:api-header] { "type": "basic", "title": "Signature (rfc2104)" } [/block] [block:callout] { "type": "info", "title": "Is this important for you?", "body": "This part of the documentation is only important if you are not using a client library. Our client libraries are built to handle this signature automatically." } [/block] For security reasons we want you to pass an API Signature calculated with the API Secret of your instance. The parameter name of this API Signature should be **ApiSignature**. You can calculate the signature using all params except the param **instance**. * Build query string (e.g. model=Page&id=17) * Calculate binary hmac hash using your instance's API Secret as key * Encode it with base64 [block:code] { "codes": [ { "code": "base64_encode(hash_hmac('sha256', http_build_query($params, null, '&'), $apiSecret, true));", "language": "php" }, { "code": "echo -n \"HTTP-QUERY-STRING\" | openssl dgst -sha256 -hmac \"API-SECRET\" -binary | openssl enc -base64", "language": "shell" }, { "code": "import urllib.request\nimport hmac\nimport hashlib\nimport base64\n\npost_data = {}\n\nhttpQueryString = urllib.parse.urlencode(post_data).encode('UTF-8')\n\napiSignature = hmac.new(b'API-SECRET', msg=httpQueryString, digestmod=hashlib.sha256).digest()", "language": "python" } ] } [/block] [block:callout] { "type": "warning", "body": "The query string has to be RFC 1738 ([https://www.ietf.org/rfc/rfc1738.txt](https://www.ietf.org/rfc/rfc1738.txt)) encoded, that means you have to replace spaces by \"+\".\nYou can probably use: [http://linux.die.net/man/1/urlencode](http://linux.die.net/man/1/urlencode)", "title": "Encoding of HTTP-Query String" } [/block]