{"_id":"563a2dbd1846790d0089531c","user":"54d4ec36f6c48a0d00f0f040","__v":1,"category":{"_id":"563a2dbb1846790d0089530b","project":"54d4ecb5f6c48a0d00f0f041","pages":["563a2dbd1846790d00895318","563a2dbd1846790d00895319","563a2dbd1846790d0089531a","563a2dbd1846790d0089531b","563a2dbd1846790d0089531c","563a2dbd1846790d0089531d","563a2dbd1846790d0089531e"],"version":"563a2dba1846790d00895309","__v":1,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-06T16:37:55.318Z","from_sync":false,"order":3,"slug":"endpoints","title":"API Endpoints"},"editedParams2":true,"editedParams":true,"project":"54d4ecb5f6c48a0d00f0f041","version":{"_id":"563a2dba1846790d00895309","__v":3,"project":"54d4ecb5f6c48a0d00f0f041","createdAt":"2015-11-04T16:09:30.844Z","releaseDate":"2015-11-04T16:09:30.844Z","categories":["563a2dbb1846790d0089530a","563a2dbb1846790d0089530b","563a2dbb1846790d0089530c","56620e60f183880d004d3217","5702e5b8f2d6f336005e9025"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"No Mashape","version_clean":"1.1.0","version":"1.1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-07T00:51:57.333Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"name":"Example Decrement Payload","code":"{\n    \"amount\": 23,\n    \"async\": false\n}","language":"json"}]},"method":"post","results":{"codes":[{"status":201,"language":"json","code":"{\n  \"meta\": \n  {\n    \":::at:::self\": \n    {\n    \t\"href\": \"https://api.instacount.io/sharded_counters/123/shards/0/operations/27f19d74-c2b3-4235-8c14-6a28c9774c89\"\n  \t}\n\t},\n  \"id\": \"27f19d74-c2b3-4235-8c14-6a28c9774c89\",\n  \"type\": \"DECREMENT\",\n  \"shardIndex\": 0,\n  \"amount\": 23,\n  \"created\": \"2015-04-07T00:30:23.574Z\"\n}","name":"OK"},{"status":400,"language":"json","code":"{\n  \"errors\": [\n    {\n      \"message\": \"Counter increment amounts must be positive numbers!\",\n      \"developerMessage\": \"Counter increment amounts must be positive numbers!\",\n      \"moreInfo\": \"https://instacount.readme.io/docs/errors\"\n    }\n  ]\n}","name":"Bad CounterName"},{"code":"{\n  \"errors\": [\n    {\n      \"message\": \"Counter decrement amounts must be positive numbers!\",\n      \"developerMessage\": \"Counter decrement amounts must be positive numbers!\",\n      \"moreInfo\": \"https://instacount.readme.io/docs/errors\"\n    }\n  ]\n}","name":"Invalid Decrement Amount","status":400,"language":"json"},{"language":"json","code":"{\n  \"errors\": [\n    {\n      \"message\": \"You must be signed-in to access the information you requested.\",\n      \"developerMessage\": \"You must enable proper Instacount Authentication!  Invalid X-Instacount-API-Key Header!\",\n      \"moreInfo\": \"https://instacount.readme.io\"\n    }\n  ]\n}","status":401}]},"settings":"","auth":"required","params":[{"_id":"55231031dbe3622300a324b6","ref":"","in":"path","required":true,"desc":"A unique name that identifies the counter.","default":"num-followers-123","type":"string","name":"name"},{"_id":"564fbd1d623284170008fb60","ref":"","in":"body","required":false,"desc":"The amount to decrement the counter.","default":"1","type":"string","name":"amount"},{"_id":"564fbd1d623284170008fb5f","ref":"","in":"body","required":false,"desc":"True if the increment operation should occur asynchronously, false if the increment should occur synchronously.","default":"false","type":"boolean","name":"async"}],"url":"/sharded_counters/:name/decrements"},"isReference":false,"order":4,"body":"Decrementing a counter is as easy as making an HTTP *POST* to a named counter's **/decrement** endpoint.  There are two supported methodologies for decrementing a counter: **synchronous** and **asynchronous**.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Asynchronous Counter Decrement\"\n}\n[/block]\nAsynchronous counter decrements are the fastest type of decrement, but will result in an eventually consistent operation.  In other words, if Instacount accepts the request to decrement, then you can reliably assume that the operation will be applied *eventually*, usually within a few seconds or less.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Use Asynchronous If You Don't Want to Wait\",\n  \"body\": \"Asynchronous decrement requests will return nearly instantly, but the actual counter won't be reduced for a few seconds.  In extremely rare cases, an async decrement may take longer to apply.  However, if you receive an HTTP  202 response code from Instacount, your decrement is guaranteed to be applied.\"\n}\n[/block]\nThe following is an example decrement request payload to reduce a counter asynchronously:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"amount\\\": 1,\\n    \\\"async\\\": true\\n}\",\n      \"language\": \"json\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\nNote that the **decrement_amount** must be a positive number.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Synchronous Counter Decrement\"\n}\n[/block]\nSynchronous counter decrements are a *slightly* slower type of decrement, but will result in a strongly consistent operation.  In other words, if Instacount responds with a 201 Created response, then the decrement can be considered to be applied and a request to get a counter will reflect the applied decrement.\n\nThe following is an example decrement request payload to reduce a counter synchronously:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"amount\\\": 1,\\n    \\\"async\\\": false\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Synchronous Counter Decrement\"\n    }\n  ]\n}\n[/block]\nNote that the **decrement_amount** must be a positive number.","excerpt":"Create and apply an decrement for a counter","slug":"decrement-counter","type":"endpoint","title":"Decrement a Counter"}

postDecrement a Counter

Create and apply an decrement for a counter

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

name:
required
stringnum-followers-123
A unique name that identifies the counter.

Body Params

amount:
string1
The amount to decrement the counter.
async:
booleanfalse
True if the increment operation should occur asynchronously, false if the increment should occur synchronously.

Examples


Result Format


Documentation

Decrementing a counter is as easy as making an HTTP *POST* to a named counter's **/decrement** endpoint. There are two supported methodologies for decrementing a counter: **synchronous** and **asynchronous**. [block:api-header] { "type": "basic", "title": "Asynchronous Counter Decrement" } [/block] Asynchronous counter decrements are the fastest type of decrement, but will result in an eventually consistent operation. In other words, if Instacount accepts the request to decrement, then you can reliably assume that the operation will be applied *eventually*, usually within a few seconds or less. [block:callout] { "type": "info", "title": "Use Asynchronous If You Don't Want to Wait", "body": "Asynchronous decrement requests will return nearly instantly, but the actual counter won't be reduced for a few seconds. In extremely rare cases, an async decrement may take longer to apply. However, if you receive an HTTP 202 response code from Instacount, your decrement is guaranteed to be applied." } [/block] The following is an example decrement request payload to reduce a counter asynchronously: [block:code] { "codes": [ { "code": "{\n \"amount\": 1,\n \"async\": true\n}", "language": "json", "name": null } ] } [/block] Note that the **decrement_amount** must be a positive number. [block:api-header] { "type": "basic", "title": "Synchronous Counter Decrement" } [/block] Synchronous counter decrements are a *slightly* slower type of decrement, but will result in a strongly consistent operation. In other words, if Instacount responds with a 201 Created response, then the decrement can be considered to be applied and a request to get a counter will reflect the applied decrement. The following is an example decrement request payload to reduce a counter synchronously: [block:code] { "codes": [ { "code": "{\n \"amount\": 1,\n \"async\": false\n}", "language": "json", "name": "Synchronous Counter Decrement" } ] } [/block] Note that the **decrement_amount** must be a positive number.

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}