{"id":22208242,"url":"https://github.com/popcron/sheets","last_synced_at":"2025-06-30T02:35:52.526Z","repository":{"id":139288006,"uuid":"151878716","full_name":"popcron/sheets","owner":"popcron","description":"C# API for Google spreadsheets for simple uses.","archived":false,"fork":false,"pushed_at":"2018-12-17T04:45:11.000Z","size":110,"stargazers_count":32,"open_issues_count":0,"forks_count":5,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-03T22:51:12.836Z","etag":null,"topics":["csharp","google","json","net","sheets"],"latest_commit_sha":null,"homepage":"","language":"C#","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/popcron.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-06T20:24:26.000Z","updated_at":"2024-11-28T02:47:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd854097-3e4d-4714-81d1-647dc1cff84b","html_url":"https://github.com/popcron/sheets","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/popcron/sheets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popcron%2Fsheets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popcron%2Fsheets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popcron%2Fsheets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popcron%2Fsheets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/popcron","download_url":"https://codeload.github.com/popcron/sheets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popcron%2Fsheets/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262699458,"owners_count":23350299,"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":["csharp","google","json","net","sheets"],"created_at":"2024-12-02T19:16:50.688Z","updated_at":"2025-06-30T02:35:52.511Z","avatar_url":"https://github.com/popcron.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Woah spreadsheet woah!!!](https://cdn.discordapp.com/attachments/377316629220032523/498001441990901760/unknown.png)\n\n# Sheets\nThis is an API that matches the version 4 of [Google's sheets API](https://developers.google.com/sheets/api/reference/rest/) for the most part. So if you'd like documentation on how to use this API, you have to consult their API instead, and use the C# bindings.\nThere is also a smaller high level layer on top, which is useful for people who just need to access the data from a 2D array.\n\n## Requirements\n- .NET Framework 4.5\n\n## Setting up the serializer\nAn abstract SheetsSerializer class exists so that you can use any JSON serializer you'd like.\n\n\u003cdetails\u003e\n    \u003csummary\u003eUnity serializer\u003c/summary\u003e\n    \n```cs\nusing UnityEngine;\n\npublic class JSONSerializer : SheetsSerializer\n{\n    public override T DeserializeObject\u003cT\u003e(string data)\n    {\n        return JsonUtility.FromJson\u003cT\u003e(data);\n    }\n\n    public override string SerializeObject(object data)\n    {\n        return JsonUtility.ToJson(data);\n    }\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n    \u003csummary\u003eNetwonsoft.Json serializer\u003c/summary\u003e\n    \n```cs\nusing Newtonsoft.Json;\n\npublic class JSONSerializer : SheetsSerializer\n{\n    public override T DeserializeObject\u003cT\u003e(string data)\n    {\n        return JsonConvert.DeserializeObject\u003cT\u003e(data);\n    }\n\n    public override string SerializeObject(object data)\n    {\n        return JsonConvert.SerializeObject(data);\n    }\n}\n```\n\u003c/details\u003e\n\n## Example\nThe requirements to using the Google Sheets API, is to have the spreadsheetId and an access token. The spreadsheetId can be retrieved from a url. You will also need to provide the `SheetsSerializer.Serializer` property with your own serializer object.\n\n`https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}`\n\nThe API token can be created from the Google API Console, for more info on this, visit [this article by google](https://cloud.google.com/docs/authentication/api-keys)\n\n```cs\npublic async void Start()\n{\n    SheetsSerializer.Serializer = new SheetsSerializer(); //TODO: Create your own custom serializer/deserializer\n    string spreadsheetId = \"\"; //TODO: Get your own spreadsheetId\n    string key = \"\";         //TODO: Get your own key token\n    \n    Authorization authorization = await Authorization.Authorize(key);\n    Spreadsheet spreadsheet = await Spreadsheet.Get(spreadsheetId, authorization);\n\n    Debug.Log(\"URL: \" + spreadsheet.URL);\n    Debug.Log(\"Title: \" + spreadsheet.Title);\n    \n    Sheet sheet = spreadsheet.Sheets[0];\n    Debug.Log(\"Rows: \" + sheet.Rows);\n    Debug.Log(\"Columns: \" + sheet.Columns);\n    \n    Cell[,] data = sheet.Data;\n    for (int x = 0; x \u003c sheet.Columns; x++)\n    {\n        for (int y = 0; y \u003c sheet.Rows; y++)\n        {\n            Debug.Log(data[x, y].Value);\n        }\n    }\n}\n```\n\nIf you'd like to use the low level API, you can use the `GetRaw()` method instead of `Get()`. The raw method alternative will give out a `SpreadsheetRaw` object, which is identical to the Google API reference.\n\nIf you want to work with both the low level and high level, you can create a spreadsheet from the low level spreadsheet by passing it into the constructor. The same can be done for converting a raw sheet to a high level sheet. This can not be done the other way around, and its by design.\n\n```cs\nSheetsSerializer.Serializer = new SheetsSerializer();\nstring key = \"\"; //TODO: Get a key\nAuthorization authorization = await Authorization.Authorize(key);\n\nSpreadsheetRaw raw = await SpreadsheetRaw.Get(spreadsheetId, token, includeGridData);\nSpreadsheet spreadsheet = await Spreadsheet.Get(spreadsheetId, token, serializer);\n\n//create a new spreadsheet from the raw data\nSpreadsheet spreadsheetConverted = new Spreadsheet(raw);\n```\n\n## Authorization\nTwo ways to authorize are implemented. Using OAuth client ID and client secret, or using a provided key from the [Google Developer Console](https://console.developers.google.com/apis/credentials).\n\n\u003cdetails\u003e\n    \u003csummary\u003eUsing keys\u003c/summary\u003e\n\n```cs\nstring key = \"\";\nAuthorizer authorizer = await Authorizer.Authorizer(key);\n```\n\u003c/details\u003e\n    \n\u003cdetails\u003e\n    \u003csummary\u003eUsing OAuth\u003c/summary\u003e\n    \n```cs\nstring clientId = \"\";\nstring clientSecret = \"\";\nAuthorizer authorizer = await Authorizer.Authorize(clientId, clientSecret);\n```\n\u003c/details\u003e\n\n*NOTE: Modifying calls require OAuth authorization*\n\n## FAQ\n- **How do I add this to my unity project?**\nDownload the dll file from the releases, and place it in your Plugins folder.\n- **Why can't I do **`new SheetSerializer()`**?**\nBecause it is an abstract class, and you have to make your own implementation of this class.\n- **What namespace?**\n Popcron.Sheets\n- **I got some kind forbidden exception**\nEnsure that your API key works, and that your spread sheet is accessible publicly.\n- **Is it rows then columns, or columns then rows?**\nNo.\n- **Is there XML documentation?**\n Yes.\n- **Does the BatchUpdate method work?**\n Untested, I don't know.\n- **What about the Create method?**\n Untested.\n- **What works?**\n The Get method, and most of the high level and low level api.\n- **I'm using the low level API and I don't know what X does?**\nLook at the Google Sheets API, because neither do I.\n- **Can I send pull requests?**\nSure.\n- **I got an error**\nSend me the steps to reproduce it and I'll try to fix it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpopcron%2Fsheets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpopcron%2Fsheets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpopcron%2Fsheets/lists"}