{"id":13623432,"url":"https://github.com/e-oj/grabity","last_synced_at":"2025-04-04T15:11:13.400Z","repository":{"id":26864747,"uuid":"111213704","full_name":"e-oj/grabity","owner":"e-oj","description":"Generate link previews from pages with Open Graph or Twitter Cards markup. Just grab it! 🎣","archived":false,"fork":false,"pushed_at":"2022-12-07T09:31:21.000Z","size":123,"stargazers_count":290,"open_issues_count":17,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T14:09:27.464Z","etag":null,"topics":["open-graph-protocol","twitter-cards"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/grabity","language":"JavaScript","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/e-oj.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}},"created_at":"2017-11-18T14:52:07.000Z","updated_at":"2025-03-19T18:45:42.000Z","dependencies_parsed_at":"2023-01-14T05:26:14.610Z","dependency_job_id":null,"html_url":"https://github.com/e-oj/grabity","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/e-oj%2Fgrabity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-oj%2Fgrabity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-oj%2Fgrabity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-oj%2Fgrabity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/e-oj","download_url":"https://codeload.github.com/e-oj/grabity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198463,"owners_count":20900080,"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":["open-graph-protocol","twitter-cards"],"created_at":"2024-08-01T21:01:31.759Z","updated_at":"2025-04-04T15:11:13.381Z","avatar_url":"https://github.com/e-oj.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"## [![Travis](https://img.shields.io/travis/e-oj/grabity.svg?style=flat-square)](https://travis-ci.org/e-oj/grabity) [![npm](https://img.shields.io/npm/l/grabity.svg?style=flat-square)](https://www.npmjs.com/package/grabity) [![npm](https://img.shields.io/npm/v/grabity.svg?style=flat-square)](https://www.npmjs.com/package/grabity)\n\n# grabity\n## Get preview data from a link. Just grab it! 🎣\n\n[og]: \u003chttp://ogp.me/\u003e\n[twitter]: \u003chttps://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/markup\u003e\n\nGrabity looks through [Open Graph](http://ogp.me/) and [Twitter Cards](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/markup) markup to get Information about a link. Its functions will return as much data as they can from the markup. If no [og] or [twitter] tags are found, it will default to the content of the \u003ctitle\u003e tag and meta description, and if either the title tag or meta description is missing, the returned property will be empty.\n\n## Getting Started:\n```\nnpm install grabity\n```\n\n## Usage:\nIt's really quite simple:\n```javascript\nlet grabity = require(\"grabity\");\n\n(async () =\u003e {\n  let it = await grabity.grabIt(\"https://github.com/e-oj/grabity\");\n\n  console.log(it);\n})();\n```\n\nShould produce:\n```\n{\n  title: 'e-oj/grabity',\n  description: 'grabity - Get preview data from a link. Just grab it! 🎣',\n  image: 'https://avatars0.githubusercontent.com/u/9700116?s=400\u0026v=4',\n  favicon: 'https://assets-cdn.github.com/favicon.ico'\n}\n```\n\n## API\n\n### grabity.grabIt(url): Gets a title, description, image, and favicon from a url\n \u003e url (required): url to be used\n\n \u003e returns: object containing title, description, image, and favicon if found\n\n Gets the [og] or [twitter] title, description and image from a url, as well as the favicon, and returns them in an object. If [og] and [twitter] tags exist for a property, the [og] tag is given preference. The [twitter] tag is selected if an [og] tag does not exist for a property. If there is no tag ([og] or [twitter]) for a property, that property is not included in the returned object.\n\n ```javascript\nlet grabity = require(\"grabity\");\n\n(async () =\u003e {\n  let it = await grabity.grabIt(\"https://www.flickr.com\");\n\n  console.log(it);\n})();\n```\n\nresult:\n```\n{\n  title: 'Flickr, a Yahoo company',\n  description: 'Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to the world, securely and privately show content to your friends and family, or blog the photos and videos you take with a cameraphone.',\n  image: 'https://farm4.staticflickr.com/3914/15118079089_489aa62638_b.jpg',\n  favicon: 'https://s.yimg.com/pw/favicon.ico'\n}\n```\n\n### grabity.grab(url): Gets all [og] + [twitter] tags and their values, as well as the favicon,\n \u003e url (required): url to be used\n\n \u003e returns: object containing all found [og] + [twitter] tags and values, and favicon\n\n Gets all existing [og] and [twitter] tags, as well as the favicon, from the markup and returns them in an object.\n\n```javascript\nlet grabity = require(\"grabity\");\n\n(async () =\u003e {\n  let tags = await grabity.grab(\"https://www.flickr.com\");\n\n  console.log(tags);\n})();\n```\n\nresult:\n```\n{\n  'og:site_name': 'Flickr',\n  'og:updated_time': '2017-11-19T21:29:36.577Z',\n  'og:title': 'Flickr, a Yahoo company',\n  'og:type': 'website',\n  'og:description': 'Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to the world, securely and privately show content to your friends and family, or blog the photos and videos you take with a cameraphone.',\n  'og:image': 'https://farm4.staticflickr.com/3914/15118079089_489aa62638_b.jpg',\n  'twitter:card': 'summary_large_image',\n  'twitter:creator': '@flickr',\n  'twitter:title': 'Flickr, a Yahoo company',\n  'twitter:description': 'Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to the world, securely and privately show content to your friends and family, or blog the photos and videos you take with a cameraphone.',\n  'twitter:image:src': 'https://farm4.staticflickr.com/3914/15118079089_489aa62638_b.jpg',\n  favicon: 'https://s.yimg.com/pw/favicon.ico'\n}\n\n```\n\u003cbr\u003e\n\n## Test\nTo test this module, cd to the project directory and run:\n```\nnpm run-script test-server\n```\n\nthen in a seperate terminal:\n```\nnpm test\n```\n*Note: The test server runs on port 9973 by default. You can change the port number in test_setup/config.js*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-oj%2Fgrabity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fe-oj%2Fgrabity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-oj%2Fgrabity/lists"}