{"id":15101362,"url":"https://github.com/contentful-labs/contentful-go","last_synced_at":"2025-10-08T08:32:25.273Z","repository":{"id":50131615,"uuid":"76127227","full_name":"contentful-labs/contentful-go","owner":"contentful-labs","description":"Contentful api SDK for GoLang","archived":true,"fork":false,"pushed_at":"2022-09-12T14:26:30.000Z","size":342,"stargazers_count":45,"open_issues_count":21,"forks_count":63,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-02T07:42:14.977Z","etag":null,"topics":["contentful","golang","sdk"],"latest_commit_sha":null,"homepage":"","language":"Go","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/contentful-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-10T17:28:31.000Z","updated_at":"2024-10-01T20:36:04.000Z","dependencies_parsed_at":"2022-08-31T05:40:47.432Z","dependency_job_id":null,"html_url":"https://github.com/contentful-labs/contentful-go","commit_stats":null,"previous_names":["tolgaakyuz/contentful-go","tolgaakyuz/contentful.go"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentful-labs%2Fcontentful-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentful-labs%2Fcontentful-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentful-labs%2Fcontentful-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentful-labs%2Fcontentful-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/contentful-labs","download_url":"https://codeload.github.com/contentful-labs/contentful-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235700110,"owners_count":19031668,"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":["contentful","golang","sdk"],"created_at":"2024-09-25T18:21:22.179Z","updated_at":"2025-10-08T08:32:19.892Z","avatar_url":"https://github.com/contentful-labs.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Godoc](https://img.shields.io/badge/godoc-Reference-brightgreen.svg?style=flat)](https://godoc.org/github.com/contentful-labs/contentful-go)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Build Status](https://travis-ci.com/contentful-labs/contentful-go.svg?token=ppF3HxXy28XU9AwHHiGX\u0026branch=master)](https://travis-ci.com/contentful-labs/contentful-go)\n\n❗ Disclaimer\n=====\n\n**This project is not actively maintained or monitored.** Feel free to fork and work on it in your account. If you want to maintain but also collaborate with fellow developers, feel free to reach out to [Contentful's Developer Relations](mailto:devrel-mkt@contentful.com) team to move the project into our community GitHub organisation [contentful-userland](https://github.com/contentful-userland/).\n\n# contentful-go\n\nGoLang SDK for [Contentful's](https://www.contentful.com) Content Delivery, Preview and Management API's.\n\n# About\n\n[Contentful](https://www.contentful.com) provides a content infrastructure for digital teams to power content in websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship digital products faster.\n\n[Go](https://golang.org) is an open source programming language that makes it easy to build simple, reliable, and efficient software.\n\n# Install\n\n`go get github.com/contentful-labs/contentful-go`\n\n# Getting started\n\nImport into your Go project or library\n\n```go\nimport (\n\tcontentful \"github.com/contentful-labs/contentful-go\"\n)\n```\n\nCreate a API client in order to interact with the Contentful's API endpoints.\n\n```go\ntoken := \"your-cma-token\" // observe your CMA token from Contentful's web page\ncma := contentful.NewCMA(token)\n```\n\n#### Organization\n\nIf your Contentful account is part of an organization, you can setup your API client as so. When you set your organization id for the SDK client, every api request will have `X-Contentful-Organization: \u003cyour-organization-id\u003e` header automatically.\n\n```go\ncma.SetOrganization(\"your-organization-id\")\n```\n\n#### Debug mode\n\nWhen debug mode is activated, sdk client starts to work in verbose mode and try to print as much informatin as possible. In debug mode, all outgoing http requests are printed nicely in the form of `curl` command so that you can easly drop into your command line to debug specific request.\n\n```go\ncma.Debug = true\n```\n\n#### Dependencies\n\n`contentful-go` stores its dependencies under `vendor` folder and uses [`dep`](https://github.com/golang/dep) to manage dependency resolutions. Dependencies in `vendor` folder will be loaded automatically by [Go 1.6+](https://golang.org/cmd/go/#hdr-Vendor_Directories). To install the dependencies, run `dep ensure`, for more options and documentation please visit [`dep`](https://github.com/golang/dep).\n\n# Using the SDK\n\n## Working with resource services\n\nCurrently SDK exposes the following resource services:\n\n* Spaces\n* APIKeys\n* Assets\n* ContentTypes\n* Entries\n* Locales\n* Webhooks\n\nEvery resource service has at least the following interface:\n\n```go\nList() *Collection\nGet(spaceID, resourceID string) \u003cResource\u003e, error\nUpsert(spaceID string, resourceID *Resource) error\nDelete(spaceID string, resourceID *Resource) error\n```\n\n#### Example\n\n```go\nspace, err := cma.Spaces.Get(\"space-id\")\nif err != nil {\n  log.Fatal(err)\n}\n\ncollection := cma.ContentTypes.List(space.Sys.ID)\ncollection, err = collection.Next()\nif err != nil {\n  log.Fatal(err)\n}\n\nfor _, contentType := range collection.ToContentType() {\n  fmt.Println(contentType.Name, contentType.Description)\n}\n```\n\n## Working with collections\n\nAll the endpoints which return an array of objects are wrapped around `Collection` struct. The main features of `Collection` are pagination and type assertion.\n\n### Pagination\nWIP\n\n### Type assertion\n\n`Collection` struct exposes the necessary converters (type assertion) such as `ToSpace()`. The following example gets all spaces for the given account:\n\n### Example\n\n```go\ncollection := cma.Spaces.List() // returns a collection\ncollection, err := collection.Next() // makes the actual api call\nif err != nil {\n  log.Fatal(err)\n}\n\nspaces := collection.ToSpace() // make the type assertion\nfor _, space := range spaces {\n  fmt.Println(space.Name)\n  fmt.Println(space.Sys.ID)\n}\n\n// In order to access collection metadata\nfmt.Println(col.Total)\nfmt.Println(col.Skip)\nfmt.Println(col.Limit)\n```\n\n## Testing\n\n```shell\n$\u003e go test\n```\n\nTo enable higher verbose mode\n\n```shell\n$\u003e go test -v -race\n```\n\n## Documentation/References\n\n### Contentful\n[Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/)\n[Content Management API](https://www.contentful.com/developers/docs/references/content-management-api/)\n[Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/)\n\n### GoLang\n[Effective Go](https://golang.org/doc/effective_go.html)\n\n## Support\n\nThis is a project created for demo purposes and not officially supported, so if you find issues or have questions you can let us know via the [issue](https://github.com/contentful-labs/contentful-go/issues/new) page but don't expect a quick and prompt response.\n\n## Contributing\n\n[WIP]\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontentful-labs%2Fcontentful-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontentful-labs%2Fcontentful-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontentful-labs%2Fcontentful-go/lists"}