{"id":25740171,"url":"https://github.com/datadotworld/dwapi-go","last_synced_at":"2025-10-05T12:17:54.345Z","repository":{"id":39856627,"uuid":"117631591","full_name":"datadotworld/dwapi-go","owner":"datadotworld","description":"Go library for managing your data.world assets","archived":false,"fork":false,"pushed_at":"2023-12-05T02:43:04.000Z","size":48,"stargazers_count":5,"open_issues_count":4,"forks_count":0,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-02-26T08:39:16.939Z","etag":null,"topics":["api-client","dwstruct-t01-dist","golang","reference-implementation"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datadotworld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2018-01-16T04:34:14.000Z","updated_at":"2024-05-15T17:23:05.000Z","dependencies_parsed_at":"2023-12-05T03:43:58.469Z","dependency_job_id":null,"html_url":"https://github.com/datadotworld/dwapi-go","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/datadotworld/dwapi-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datadotworld%2Fdwapi-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datadotworld%2Fdwapi-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datadotworld%2Fdwapi-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datadotworld%2Fdwapi-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datadotworld","download_url":"https://codeload.github.com/datadotworld/dwapi-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datadotworld%2Fdwapi-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262842896,"owners_count":23373164,"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":["api-client","dwstruct-t01-dist","golang","reference-implementation"],"created_at":"2025-02-26T08:37:05.880Z","updated_at":"2025-10-05T12:17:54.267Z","avatar_url":"https://github.com/datadotworld.png","language":"Go","readme":"# dwapi-go\n\n[![GoDoc](https://godoc.org/github.com/datadotworld/dwapi-go/dwapi?status.svg)](https://godoc.org/github.com/datadotworld/dwapi-go/dwapi)\n\nThis package makes it easy to use [data.world's REST API](https://apidocs.data.world/api) with Go.\n\nUsers can:\n* Create and update datasets, projects, metadata, and files\n* Query datasets using SQL and SPARQL\n* Download files and entire datasets\n\n## Installation\n\n```bash\ngo get github.com/datadotworld/dwapi-go/dwapi\n```\n\n## Usage\n\nThe full package documentation is available at https://godoc.org/github.com/datadotworld/dwapi-go/dwapi.\n\nYou can also check out the API documentation at https://apidocs.data.world/api for specifics on the endpoints.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/datadotworld/dwapi-go/dwapi\"\n)\n\nfunc main() {\n\t// new client\n\ttoken := os.Getenv(\"DW_AUTH_TOKEN\")\n\tdw := dwapi.NewClient(token)\n\n\t// get info on the current user\n\tuser, err := dw.User.Self()\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"User.Self() returned an error:\", err)\n\t\tos.Exit(1)\n\t}\n\tfmt.Println(\"Name:\", user.DisplayName)\n\tfmt.Println(\"Creation Date:\", user.Created)\n\tfmt.Println(\"-----\")\n\t/* output:\n\tName: My Display Name\n\tCreation Date: 2016-07-13T23:38:44.026Z\n\t-----\n\t*/\n\n\t// create a new dataset\n\towner := \"my-username\"\n\trequest := dwapi.DatasetCreateRequest{\n\t\tTitle:       \"My Awesome Dataset\",\n\t\tDescription: \"A short description\",\n\t\tSummary:     \"A long description\",\n\t\tTags:        []string{\"first\", \"puppies and kittens\"},\n\t\tLicense:     \"PDDL\",\n\t\tVisibility:  \"PRIVATE\",\n\t}\n\tcreateResp, err := dw.Dataset.Create(owner, \u0026request)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Dataset.Create() returned an error:\", err)\n\t\tos.Exit(1)\n\t}\n\tfmt.Println(\"Create Response Message:\", createResp.Message)\n\tfmt.Println(\"Dataset URI:\", createResp.URI)\n\tfmt.Println(\"-----\")\n\t/* output:\n\tResponse Message: Dataset created successfully.\n\tDataset URI: https://data.world/my-username/my-awesome-dataset\n\t-----\n\t*/\n\n\t// retrieve the metadata for a dataset\n\tpattern := regexp.MustCompile(`https://data.world/(?:.*)/(.*)`)\n\tdatasetid := pattern.FindStringSubmatch(createResp.URI)[1]\n\n\tretrieveResp, err := dw.Dataset.Retrieve(owner, datasetid)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Dataset.Retrieve() returned an error:\", err)\n\t\tos.Exit(1)\n\t}\n\tfmt.Println(\"Title:\", retrieveResp.Title)\n\tfmt.Println(\"Description:\", retrieveResp.Description)\n\tfmt.Println(\"Access Level:\", retrieveResp.AccessLevel)\n\tfmt.Println(\"Creation Date:\", retrieveResp.Created)\n\tfmt.Println(\"Last Updated Date:\", retrieveResp.Updated)\n\tfmt.Println(\"Dataset Status:\", retrieveResp.Status)\n\tfmt.Println(\"-----\")\n\t/* output:\n\tTitle: My Awesome Dataset\n\tDescription: A short description\n\tAccess Level: ADMIN\n\tCreation Date: 2018-11-21T17:32:40.057Z\n\tLast Updated Date: 2018-11-21T17:32:40.057Z\n\tDataset Status: NEW\n\t-----\n\t*/\n\n\t// upload a file\n\ts := []string{\"first_name,last_name\", \"Abe,Marcos\", \"Abby,Johnson\"}\n\tsj := strings.Join(s, \"\\n\")\n\ttestFilePath := filepath.Join(os.TempDir(), \"test-file.csv\")\n\tif err = ioutil.WriteFile(testFilePath, []byte(sj), 0644); err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Dataset.UploadFile() returned an error while creating a file:\", err)\n\t\tos.Exit(1)\n\t}\n\tdefer os.Remove(testFilePath)\n\n\tuploadResp, err := dw.Dataset.UploadFile(owner, datasetid, \"test-file.csv\", testFilePath, false)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Dataset.UploadFile() returned an error:\", err)\n\t\tos.Exit(1)\n\t}\n\tfmt.Println(\"Upload Response Message:\", uploadResp.Message)\n\tfmt.Println(\"-----\")\n\t/* output:\n\tResponse Message: File uploaded.\n\t-----\n\t*/\n\n\t// delete a dataset\n\tdeleteResp, err := dw.Dataset.Delete(owner, datasetid)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Dataset.Delete() returned an error:\", err)\n\t\tos.Exit(1)\n\t}\n\tfmt.Println(\"Delete Response Message:\", deleteResp.Message)\n\tfmt.Println(\"-----\")\n\t/* output:\n\tDelete Response Message: Dataset has been successfully deleted.\n\t-----\n\t*/\n}\n```\n\n## Changing the hostname\n\nThe API calls are made to `https://api.data.world` by default, but the URL can be changed by setting the `DW_API_HOST` environment variable.\n\nFor customers in a single-tenant environment, you can also use the `DW_ENVIRONMENT` variable to alter the default URL. For example, for the customer `customer`, setting it will alter the URL to `https://api.customer.data.world`.\n\nAdditionally, the hostname can also be changed by explicitly setting the `BaseURL` property of the client, i.e.:\n```\ndw = dwapi.NewClient(\"token\")\ndw.BaseURL = \"http://localhost:1010/v0\"\n```\n_Notice that the stage also needs to be set if going down this path._\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatadotworld%2Fdwapi-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatadotworld%2Fdwapi-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatadotworld%2Fdwapi-go/lists"}