{"id":18238186,"url":"https://github.com/patchoulish/gravatar-dotnet","last_synced_at":"2026-02-23T11:16:45.659Z","repository":{"id":260982236,"uuid":"882801967","full_name":"patchoulish/gravatar-dotnet","owner":"patchoulish","description":"A .NET library for interacting with the Gravatar API","archived":false,"fork":false,"pushed_at":"2024-12-07T01:58:07.000Z","size":70,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T11:45:52.397Z","etag":null,"topics":["api","avatar","dotnet","gravatar","profile"],"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/patchoulish.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-03T19:47:50.000Z","updated_at":"2024-12-07T01:58:10.000Z","dependencies_parsed_at":"2024-11-04T03:17:53.699Z","dependency_job_id":"ab39d730-7b55-4e32-932b-019407f54416","html_url":"https://github.com/patchoulish/gravatar-dotnet","commit_stats":null,"previous_names":["patchoulish/gravatar-dotnet"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patchoulish%2Fgravatar-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patchoulish%2Fgravatar-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patchoulish%2Fgravatar-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patchoulish%2Fgravatar-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patchoulish","download_url":"https://codeload.github.com/patchoulish/gravatar-dotnet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648899,"owners_count":20972944,"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","avatar","dotnet","gravatar","profile"],"created_at":"2024-11-05T03:04:18.293Z","updated_at":"2026-02-23T11:16:40.625Z","avatar_url":"https://github.com/patchoulish.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gravatar-dotnet [![CI](https://github.com/patchoulish/gravatar-dotnet/actions/workflows/ci.yml/badge.svg)](https://github.com/patchoulish/gravatar-dotnet/actions/workflows/ci.yml)\nA .NET library for interacting with the [Gravatar](https://gravatar.com/) API.\n\n\n## Installation\nInstall the library via [NuGet](https://www.nuget.org/packages/gravatar-dotnet):\n```bash\ndotnet add package gravatar-dotnet\n```\n\n### Extensions\nInstall optional library extensions for more functionality, depending on your use case.\n#### Dependency Injection\nIntegrate gravatar-dotnet and your DI container of choice. Install the extension library via [NuGet](https://www.nuget.org/packages/gravatar-dotnet-dependencyinjection):\n```bash\ndotnet add package gravatar-dotnet-dependencyinjection\n```\n#### ASP.Net Core Additions\nIntegrate gravatar-dotnet and ASP.NET Core with Razor Tag Helpers for avatars and profile QR codes. Install the extension library via [NuGet](https://www.nuget.org/packages/gravatar-dotnet-aspnetcore):\n```bash\ndotnet add package gravatar-dotnet-aspnetcore\n```\n\n\n## Usage\n1. Obtain an API key from the [Gravatar Developer Dashboard](https://gravatar.com/developers/applications) (requires a Gravatar account and developer application).\n2. Pass the API key into a new instance of the `GravatarService` class or use a configured `HttpClient` if advanced configuration (e.g., proxies) is required.\n3. Use the methods available on `GravatarService` to interact with the Gravatar API.\n\n### Initialization\nThe library can be initialized in three ways:\n#### Basic Initialization\nPass in your API key directly:\n```csharp\nvar gravatar = new GravatarService(\"YOUR_GRAVATAR_API_KEY\");\n```\n#### Advanced Initialization\nUse an existing `HttpClient`, ensuring that `BaseAddress` and an `Authorization` header have been set:\n```csharp\nvar httpClient = new HttpClient(\n\tnew GravatarDelegatingHandler()\n\t{\n\t\tInnerHandler = new HttpClientHandler()\n\t},\n\tdisposeHandler: true)\n{\n\tBaseAddress = new Uri(\"https://api.gravatar.com/v3/\"),\n\tTimeout = TimeSpan.FromSeconds(5)\n};\n\nhttpClient.DefaultRequestHeaders.Add(\n\t$\"Authorization\",\n\t$\"Bearer YOUR_GRAVATAR_API_KEY\");\n\nvar gravatar = new GravatarService(httpClient);\n```\n#### Dependency Injection\nIf you've installed the appropriate extension library.\n1. Register `GravatarService` with your dependency container:\n```csharp\nservices.AddGravatarHttpClient(options =\u003e\n{\n\toptions.BaseUrl = new Uri(\"https://api.gravatar.com/v3/\");\n\toptions.ApiKey = \"YOUR_GRAVATAR_API_KEY\";\n});\n```\n2. Inject `IGravatarService` where needed:\n```csharp\npublic class MyClass\n{\n    private readonly IGravatarService gravatar;\n\n    public MyClass(IGravatarService gravatar)\n    {\n        this.gravatar = gravatar;\n    }\n}\n```\n\n### Getting an Avatar URL\nYou can construct a valid Gravatar Avatar URL as follows:\n```csharp\nvar gravatarAvatarUrl =\n\tGravatarHelper.GetAvatarUrl(\n\t\t\"self@example.com\",\n\t\tsize: 64,\n\t\tdefaultValue: GravatarAvatarDefault.Identicon,\n\t\tforceDefaultValue: false,\n\t\trating: GravatarAvatarRating.G,\n\t\twithFileExtension: false)\n```\nTo retrieve the avatar image, make a HTTP GET request to the URL that is returned.\n\n### Getting a Profile\n```csharp\nvar gravatarProfile =\n    await gravatar.GetProfileAsync(\n        GravatarHelper.GetEmailAddressHash(\n            \"self@example.com\"));\n```\n\n### Getting a Profile QR Code URL\nYou can construct a valid Gravatar Profile QR Code URL as follows:\n```csharp\nvar gravatarProfileQRCodeUrl =\n\tGravatarHelper.GetProfileQRCodeUrl(\n\t\t\"self@example.com\",\n\t\tsize: 256,\n\t\ttype: GravatarProfileQRCodeType.Logo,\n\t\tversion: GravatarProfileQRCodeVersion.Modern)\n```\nTo retrieve the profile QR code image, make a HTTP GET request to the URL that is returned.\n\n### Using Tag Helpers\nIf you've installed the appropriate extension library, add the following to your `_ViewImport.cshtml`:\n```razor\n@addTagHelper *, Gravatar.Extensions.AspNetCore\n```\n\nTo automatically construct the `src` URL for an `img` tag from a Gravatar Avatar URL, use `gravatar-avatar` and the various `gravatar-*` attributes supplied.\n```razor\n\u003cimg gravatar-avatar\n     gravatar-email-address=\"Context.User.Claims...\"\n     gravatar-default=\"identicon\"\n     ... /\u003e\n```\n\nTo automatically construct the `src` URL for an `img` tag from a Gravatar Profile QR Code URL, use `gravatar-profile-qrcode` and the various `gravatar-*` attributes supplied.\n```razor\n\u003cimg gravatar-profile-qrcode\n     gravatar-email-address=\"Context.User.Claims...\"\n     ... /\u003e\n```\n\n\n## Documentation\nRefer to the [Usage](#usage) section above for a quick start, or consult the inline documentation while working in your IDE. For detailed information about the underlying API endpoints, parameters, and expected responses, refer to the [official Gravatar API documentation](https://docs.gravatar.com/api/profiles/rest-api/).\n\n\n## Contributing\nContributions are welcome! To contribute, fork the repository, create a new branch, and submit a pull request with your changes. Please make sure all tests pass before submitting.\n\n\n## License\nThis project is licensed under the MIT license. See `license.txt` for full details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatchoulish%2Fgravatar-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatchoulish%2Fgravatar-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatchoulish%2Fgravatar-dotnet/lists"}