{"id":15396998,"url":"https://github.com/ryanhefner/contentful-parsers","last_synced_at":"2025-08-08T16:09:02.485Z","repository":{"id":54684427,"uuid":"178464990","full_name":"ryanhefner/contentful-parsers","owner":"ryanhefner","description":"🧰 Toolbox of useful parsers to use when working with Contentful API responses.","archived":false,"fork":false,"pushed_at":"2025-05-06T18:50:35.000Z","size":992,"stargazers_count":9,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-17T15:26:48.722Z","etag":null,"topics":["contentful","contentful-api","contentful-js-sdk","next-contentful","react-contentful"],"latest_commit_sha":null,"homepage":"https://www.pkgstats.com/pkg:contentful-parsers","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/ryanhefner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"ryanhefner","patreon":"ryanhefner","open_collective":"ryanhefner","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-03-29T19:31:19.000Z","updated_at":"2023-04-24T19:43:55.000Z","dependencies_parsed_at":"2022-08-14T00:00:29.712Z","dependency_job_id":null,"html_url":"https://github.com/ryanhefner/contentful-parsers","commit_stats":null,"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"purl":"pkg:github/ryanhefner/contentful-parsers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Fcontentful-parsers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Fcontentful-parsers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Fcontentful-parsers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Fcontentful-parsers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanhefner","download_url":"https://codeload.github.com/ryanhefner/contentful-parsers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Fcontentful-parsers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269449048,"owners_count":24419008,"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","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["contentful","contentful-api","contentful-js-sdk","next-contentful","react-contentful"],"created_at":"2024-10-01T15:35:41.899Z","updated_at":"2025-08-08T16:09:02.440Z","avatar_url":"https://github.com/ryanhefner.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ryanhefner","https://patreon.com/ryanhefner","https://opencollective.com/ryanhefner"],"categories":[],"sub_categories":[],"readme":"# 🧰 contentful-parsers\n\n[![npm](https://img.shields.io/npm/v/contentful-parsers?style=flat-square)](https://www.pkgstats.com/pkg:contentful-parsers)\n[![NPM](https://img.shields.io/npm/l/contentful-parsers?style=flat-square)](https://www.pkgstats.com/pkg:contentful-parsers)\n[![npm](https://img.shields.io/npm/dt/contentful-parsers?style=flat-square)](https://www.pkgstats.com/pkg:contentful-parsers)\n[![Coveralls github](https://img.shields.io/coveralls/github/ryanhefner/contentful-parsers?style=flat-square)](https://coveralls.io/github/ryanhefner/contentful-parsers)\n![CircleCI](https://img.shields.io/circleci/build/github/ryanhefner/contentful-parsers?style=flat-square)\n![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/ryanhefner/contentful-parsers?style=flat-square)\n\n\nToolbox of useful parsers to use when working with Contentful API responses.\n\n## Install\n\nVia [npm](https://npmjs.com/package/contentful-parsers)\n\n```sh\nnpm install contentful-parsers\n```\n\nVia [Yarn](http://yarn.fyi/contentful-parsers)\n\n```sh\nyarn add contentful-parsers\n```\n\n## Parsers\n\n### `fieldsParser`\nProbably the most common parser of the lot. This will take a Contentful response,\neither an array or a single item, and parse the items to flatten all of the `fields`\nobjects and remove the majority of the `sys` objects, except for a reference to\nthe `sys.contentType.sys.id`, in case you are doing any based on that for your\nrendering.\n\n#### How to use\n\n```js\nimport contentful from 'contentful';\nimport { fieldsParser } from 'contentful-parsers';\n\nconst client = contentful.createClient({\n  space: '[SPACE_ID]',\n  accessToken: '[ACCESS_TOKEN]',\n});\n\nconst response = await client.getEntry('[ENTRY_ID]');\nconst data = fieldsParser(response);\n```\n\n\n### `graphqlParser`\nTakes a standard standard REST response from the Contentful API and restructures it\nto allow it to be queryable via a GraphQL query.\n\nSince this will probably commonly be used with `graphql-anywhere` for performing the\nqueries against the parsed data, a basic resolver is included in the paackage as\nwell, `contentfulResolver`.\n\n#### How to use\n\n```js\nimport { graphql } from 'graphql-anywhere/lib/async'\nimport contentful from 'contentful';\nimport { graphqlParser, contentfulResolver } from 'contentful-parsers';\n\nconst entryQuery = gql`\n  entry {\n    sys {\n      id\n    }\n    title\n    copy\n  }\n`\n\nconst client = contentful.createClient({\n  space: '[SPACE_ID]',\n  accessToken: '[ACCESS_TOKEN]',\n});\n\nconst response = await client.getEntry('[ENTRY_ID]');\nconst parsedData = graphqlParser('entry', response);\n\ngraphql(\n  contentfulResolver,\n  entryQuery,\n  parsedData,\n)\n  .then(data =\u003e {\n    // data -\u003e Contentful model filtered via GraphQL query\n  })\n  .catch(error =\u003e console.error(error));\n```\n\n\n## License\n\n[MIT](LICENSE) © [Ryan Hefner](https://www.ryanhefner.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanhefner%2Fcontentful-parsers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanhefner%2Fcontentful-parsers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanhefner%2Fcontentful-parsers/lists"}