{"id":17001652,"url":"https://github.com/shresht7/pocket-api","last_synced_at":"2025-03-22T08:48:24.692Z","repository":{"id":103221671,"uuid":"536992457","full_name":"Shresht7/Pocket-API","owner":"Shresht7","description":"A thin wrapper client for the Pocket API","archived":false,"fork":false,"pushed_at":"2022-09-16T11:51:36.000Z","size":24,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T09:09:37.616Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shresht7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-15T11:21:27.000Z","updated_at":"2022-09-15T13:51:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"deef4b8b-5d88-4556-9c0a-6ccbcf99081d","html_url":"https://github.com/Shresht7/Pocket-API","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shresht7%2FPocket-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shresht7%2FPocket-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shresht7%2FPocket-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shresht7%2FPocket-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shresht7","download_url":"https://codeload.github.com/Shresht7/Pocket-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244931586,"owners_count":20534010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T04:25:40.376Z","updated_at":"2025-03-22T08:48:24.652Z","avatar_url":"https://github.com/Shresht7.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pocket API\n\nA thin wrapper client for the Pocket API.\n\n⚠ Work-in-Progress ⚠\n\n\u003c!-- \n## Install\n\n```\nnpm install Shresht7/pocket-api\n```\n --\u003e\n\n## Usage\n\nCreate a `PocketClient` using your `consumer_key` to interact with the Pocket API.\n\n```ts\nimport { PocketClient } from 'pocket-api'\n\n//  This assumes you have already completed the auth flow and\n//  have obtained these tokens.\nconst consumer_key = 'YOUR_CONSUMER_KEY'\nconst request_token = 'REQUEST_TOKEN'\nconst access_token = 'ACCESS_TOKEN'\n\nconst pocket = new PocketClient({ consumer_key, access_token })\n```\n\nOnce the client has been authorized (i.e. has a valid `access_token`), you can start making API requests. Read more about [Authorization](#authorization)\n\n```ts\nconst response = await pocket.retrieve({ count: 3 })\nconsole.log(response.ok, response.status, response.statusText, await response.json())\n```\n\nFor API documentation, see [Reference](#reference).\n\n## API Reference\n\n[Pocket API Documentation](https://getpocket.com/developer/docs/overview)\n\n### `add`\n\nAdd item to the user's Pocket\n\nhttp://getpocket.com/developer/docs/v3/add\n\n```ts\npocket.add({\n    url: 'https://example.com',\n    title: 'Example',\n    tags: 'tag1,tag2'\n})\n```\n\nAccepts a single object with the following parameters\n\n| Parameter  | Description                                                                                                                                                                                                             | Required |\n| :--------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------: |\n|   `url`    | The URL of the item you want to save                                                                                                                                                                                    |    ✔     |\n|  `title`   | Title of the item. This can be included for cases where the item does not have a title, which is typical for image or PDF URLs. If Pocket detects a title from the contents of the page, this parameter will be ignored |          |\n|   `tags`   | A comma separated list of tags to apply to the item                                                                                                                                                                     |          |\n| `tweet_id` | If you are adding Pocket support to a Twitter client, please send along a reference to the tweet status id. This allows pocket to show the original tweet alongside the article.                                        |\n|            |\n\n\u003e Your consumer_key must have the ADD permission\n\n### `retrieve`\n\nRetrieve items from the user's Pocket list\n\n```ts\n//  retrieve 10 items\nconst { list } = await pocket.retrieve({\n    count: 10,\n})\n```\n\n\u003e Your consumer_key must have the RETRIEVE permission\n\n### `modify`\n\nModify items from the user's Pocket list\n\n```ts\nconst modification = await pocket.modify([\n        { action: 'tag_delete', tag: 'old' },\n        { action: 'tag_rename', old_tag: 'typo', new_tag: 'typography' },\n])\n```\n\n\u003e Your consumer_key must have the MODIFY permission\n\n## Authorization\n\n### 1. Consumer Key\n\nRegister your app with Pocket using the developer portal.\n\nhttp://getpocket.com/developer/apps/new\n\n\u003e Note: The permissions you grant to this app **cannot** be changed at a later date.\n\n### 2. Request Token\n\nOnce you have the `consumer_key`, you can obtain the `request_token` using the `getRequestToken()` method.\n\n```ts\nconst redirect_uri = 'http://localhost:3000'  // You will be redirected here after authorization\nconst pocket = new PocketClient({ consumer_key, redirect_uri })\n\n//  Request the request token\nawait pocket.getRequestToken()  //  returns the request_token, but is also tracked internally in the class\n```\n\nOnce you have the request token, you have to redirect the user to the authorization url to authenticate the app.\n\n```ts\nconst authURL = pocket.getAuthURL()\n//  Send the user to this URL for authorization\n```\n\n### 3. Access Token\n\nOnce the user has authorized the app, they will be redirected to the `redirect_uri`. You can then request the `access_token` using the `getAccessToken()` method.\n\n```ts\nawait pocket.getAccessToken()   //  returns the access_token, but also tracks it internally\n```\n\nOnce you have the `access_token`, it will be used along with the `consumer_key` on all subsequent API calls.\n\n### 4. Future\n\nYou do not need to reauthenticate every time the app runs, you can just stow the credentials and retrieve them as needed.\n\n```ts\nconst consumer_key = 'YOUR_CONSUMER_KEY'\nconst access_token = 'YOUR_ACCESS_TOKEN'\nconst pocket = new PocketClient({ consumer_key, access_token })\n//  Use the Pocket API\n```\n\n---\n\n## 📑 License\n\n\u003e [MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshresht7%2Fpocket-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshresht7%2Fpocket-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshresht7%2Fpocket-api/lists"}