{"id":13414074,"url":"https://github.com/playlyfe/playlyfe-go-sdk","last_synced_at":"2026-01-14T20:18:19.753Z","repository":{"id":32636251,"uuid":"36222457","full_name":"playlyfe/playlyfe-go-sdk","owner":"playlyfe","description":"This is the official Playlyfe Golang Sdk","archived":false,"fork":false,"pushed_at":"2016-03-06T10:21:06.000Z","size":73,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-25T05:25:24.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/playlyfe.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":"2015-05-25T09:34:47.000Z","updated_at":"2022-09-27T09:44:46.000Z","dependencies_parsed_at":"2022-09-03T02:00:14.395Z","dependency_job_id":null,"html_url":"https://github.com/playlyfe/playlyfe-go-sdk","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/playlyfe/playlyfe-go-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playlyfe%2Fplaylyfe-go-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playlyfe%2Fplaylyfe-go-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playlyfe%2Fplaylyfe-go-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playlyfe%2Fplaylyfe-go-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/playlyfe","download_url":"https://codeload.github.com/playlyfe/playlyfe-go-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playlyfe%2Fplaylyfe-go-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-07-30T20:01:56.938Z","updated_at":"2026-01-14T20:18:19.736Z","avatar_url":"https://github.com/playlyfe.png","language":"Go","funding_links":[],"categories":["第三方api","Third-party APIs","第三方API`第三方API 汇总`","第三方API","Utility","\u003cspan id=\"第三方api-third-party-apis\"\u003e第三方API Third-party APIs\u003c/span\u003e"],"sub_categories":["实用程序/Miscellaneous","Utility/Miscellaneous","查询语","交流","HTTP Clients","Advanced Console UIs","Fail injection","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"![Playlyfe Go SDK](https://dev.playlyfe.com/images/assets/pl-go-sdk.png \"Playlyfe Go SDK\")\n\n# Playlyfe Go SDK [![Go Report Card](https://goreportcard.com/badge/github.com/playlyfe/playlyfe-go-sdk)](https://goreportcard.com/report/github.com/playlyfe/playlyfe-go-sdk) [![GoDoc](https://godoc.org/github.com/playlyfe/playlyfe-go-sdk?status.svg)](https://godoc.org/github.com/playlyfe/playlyfe-go-sdk) [![coverage](http://gocover.io/_badge/github.com/playlyfe/playlyfe-go-sdk)](https://gocover.io/github.com/playlyfe/playlyfe-go-sdk)\n\nThis is the official OAuth 2.0 Go or Golang client SDK for the Playlyfe API.\nIt supports the `client_credentials` and `authorization code` OAuth 2.0 flows.\nFor a complete API Reference checkout [Playlyfe Developers](https://dev.playlyfe.com/docs/api.html) for more information.\n\n# Examples\nThe Playlyfe class allows you to make rest api calls like GET, POST, .. etc.  \nTo get started create a new playlyfe object using client credentials flow and then start making requests\n```go\nimport \"github.com/playlyfe/playlyfe-go-sdk\"\n\ntype Player struct {\n    ID string `json:\"id\"`\n    Alias string `json:\"alias\"`\n}\n\nvar johny Player\n\nfunc main() { \n    pl := playlyfe.NewClientV2(\"Your client id\", \"Your client secret\", nil, nil)\n    err := pl.Get(\"/runtime/player\", playlyfe.H{\"player_id\": \"johny\"}, johny)  // To get player profile\n}\n```\n\n# Install\n```sh\ngo get github.com/playlyfe/playlyfe-go-sdk\n```\n# Using\n### Create a client\n  If you haven't created a client for your game yet just head over to [Playlyfe](http://playlyfe.com) and login into your account, and go to the game settings and click on client.\n\n###1. Client Credentials Flow\nIn the client page select Yes for both the first and second questions\n![client](https://cloud.githubusercontent.com/assets/1687946/7930229/2c2f14fe-0924-11e5-8c3b-5ba0c10f066f.png)\n```go\nimport \"github.com/playlyfe/playlyfe-go-sdk\"\n\npl := playlyfe.NewClientV2(\"Your client id\", \"Your client secret\", nil, nil)\n```\n###2. Authorization Code Flow\nIn the client page select yes for the first question and no for the second\n![auth](https://cloud.githubusercontent.com/assets/1687946/7930231/2c31c1fe-0924-11e5-8cb5-73ca0a002bcb.png)\n```go\nimport \"github.com/playlyfe/playlyfe-go-sdk\"\n\npl := playlyfe.NewCodeV2(\"Your client id\", \"Your client secret\", \"redirect_uri\", nil, nil)\n```\nIn development the sdk caches the access token in memory so you don\"t need to  the persist access token object. But in production it is highly recommended to persist the token to a database. It is very simple and easy to do it with redis. You can see the test cases for more examples.\n\nIn production you need to pass the Load and Store functions whose signature is like this,\n```go\nload func() (token string, expires_at int64) {\n    println(\"Loading from redis\")\n    return \"\", 50\n},\nstore func(token string, expires_at int64) {\n    println(\"Storing to redis\")\n}\n```\n## 3. Custom Login Flow using JWT(JSON Web Token)\nIn the client page select no for the first question and yes for the second\n![jwt](https://cloud.githubusercontent.com/assets/1687946/7930230/2c2f2caa-0924-11e5-8dcf-aed914a9dd58.png)\n```go\nimport \"github.com/playlyfe/playlyfe-go-sdk\"\n\ntoken, err := playlyfe.createJWT(\"your client_id\", \"your client_secret\", \n    \"player_id\", // The player id associated with your user\n    []string{\"player.runtime.read\", \"player.runtime.write\"}, // The scopes the player has access to\n    3600; // 1 hour expiry Time\n)\n```\nThis is used to create jwt token which can be created when your user is authenticated. This token can then be sent to the frontend and or stored in your session. With this token the user can directly send requests to the Playlyfe API as the player.\n\n# Client Scopes\n![Client](https://cloud.githubusercontent.com/assets/1687946/9349193/e00fe91c-465f-11e5-8094-6e03c64a662c.png)\n\nYour client has certain access control restrictions. There are 3 kind of resources in the Playlyfe REST API they are,\n\n1.`/admin` -\u003e routes for you to perform admin actions like making a player join a team\n\n2.`/design` -\u003e routes for you to make design changes programmatically\n\n3.`/runtime` -\u003e routes which the users will generally use like getting a player profile, playing an action\n\nThe resources accessible to this client can be configured to have a read permission that means only `GET` requests will work.\n\nThe resources accessible to this client can be configured to have a write permission that means only `POST`, `PATCH`, `PUT`, `DELETE` requests will work.\n\nThe version restriction is only for the design resource and can be used to restrict the client from accessing any version of the game design other than the one specified. By default it allows all.\n\nIf access to a route is not allowed and then you make a request to that route then you will get an error like this,\n```json\n{\n  \"error\": \"access_denied\",\n  \"error_description\": \"You are not allowed to access this api route\"\n}\n```\n\n# Methods\n**API**\n```go\nerror API(\"GET\", // The request method can be GET/POST/PUT/PATCH/DELETE\n    \"\", // The api route to get data from\n    playlyfe.H{}, // The query params that you want to send to the route\n    struct{} ,// The data you want to post to the api\n    result interface{}, // The unmarshalled data\n    false // Whether you want the response to be in raw string form or json\n)\n```\n**Get**\n```go\nerror Get(\"\", // The api route to get data from\n    playlyfe.H{}, // The query params that you want to send to the,\n    result interface{}, // The unmarshalled data\n)\n```\n**Post**\n```go\nerror Post(\"\", // The api route to post data to\n    playlyfe.H{}, // The query params that you want to send to the route\n    struct{},// The data you want to post to the api\n    result interface{}, // The unmarshalled data\n)\n```\n**Patch**\n```go\nerror Patch(\"\" // The api route to patch data\n    playlyfe.H{} // The query params that you want to send to the route\n    struct{} ,// The data you want to post to the api\n    result interface{}, // The unmarshalled data\n)\n```\n**Put**\n```go\nerror Put(\"\" // The api route to put data\n    playlyfe.H{}, // The query params that you want to send to the route\n    struct{} ,// The data you want to post to the api\n    result interface{}, // The unmarshalled data\n)\n```\n**Delete**\n```go\nerror Delete(\"\" // The api route to delete the component\n    playlyfe.H{} // The query params that you want to send to the route,\n    result interface{}, // The unmarshalled data\n)\n```\n**Get Login URL**\n```go\nGetLoginURL() string\n//This will return the url to which the user needs to be redirected for the user to login.\n```\n\n**Exchange Code**\n```go\nExchangeCode(code string)\n//This is used in the auth code flow so that the sdk can get the access token.\n//Before any request to the playlyfe api is made this has to be called atleast once.\n//This should be called in the the route/controller which you specified in your redirect_uri\n```\n\n**Errors**  \nAn ```*Error``` is returned whenever an error from the PlaylyfeAPI occurs in each call.The Error contains a Name and Description field which can be used to determine the type of error that occurred.\n\nYou have to type cast the error to a *PlaylyfeError first like this,\n```go\nerr := pl.Get(\"/player\", playlyfe.H{\"player_id\": \"student1\"}, \u0026player)\nif pe, ok := err.(*playlyfe.Error); ok {\n    return pe\n} else {\n    panic(err) // do what needs to be done on this type of error\n}\n```\n\n\nYou can read the docs at [GoDoc](https://godoc.org/github.com/playlyfe/playlyfe-go-sdk)\n\n\nLicense\n=======\nPlaylyfe Go SDK  \nhttp://dev.playlyfe.com/  \nCopyright(c) 2014-2015, Playlyfe IT Solutions Pvt. Ltd, support@playlyfe.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaylyfe%2Fplaylyfe-go-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplaylyfe%2Fplaylyfe-go-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaylyfe%2Fplaylyfe-go-sdk/lists"}