https://github.com/akacdev/replit
An async and lightweight C# library for interacting with Replit APIs.
https://github.com/akacdev/replit
api client driver graphql repler replit replit-driver replit-graphql
Last synced: 3 months ago
JSON representation
An async and lightweight C# library for interacting with Replit APIs.
- Host: GitHub
- URL: https://github.com/akacdev/replit
- Owner: akacdev
- License: mit
- Created: 2022-11-13T12:34:01.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-11-18T16:51:05.000Z (almost 2 years ago)
- Last Synced: 2025-06-10T02:11:55.757Z (4 months ago)
- Topics: api, client, driver, graphql, repler, replit, replit-driver, replit-graphql
- Language: C#
- Homepage: https://www.nuget.org/packages/Replit.GraphQL
- Size: 18.6 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Replit
![]()
An async and lightweight C# library for interacting with Replit APIs.## Usage
Provides an easy interface for interacting with Replit APIs. Currently distributed packages:
* `Replit.GraphQL` ([NuGet](https://www.nuget.org/packages/Replit.GraphQL)) ([GitHub](https://github.com/actually-akac/Replit/tree/master/Replit.GraphQL)) - Wrapper for the GraphQL API.To get started, add the library into your solution with either the `NuGet Package Manager` or the `dotnet` CLI.
```rust
dotnet add package Replit.GraphQL
```For the primary classes to become available, import the used namespace.
```csharp
using Replit.GraphQL;
```> **Warning**
> Certain actions require you to pass a valid **session identifier** (`connect.sid`) cookie. You can obtain this from the browser `Developer Tools` while logged in.
> Unsure of how to obtain this value? See [this guide](https://replit.com/talk/learn/How-to-Get-Your-SID-Cookie/145979) written by [RayhanADev](https://replit.com/@RayhanADev).
> If you are on mobile, you can alternatively use [this web based form](https://extract-sid.ironcladdev.repl.co) made by [IroncladDev](https://replit.com/@IroncladDev).## Features
- Built for `.NET 6` and `.NET 7`
- Fully **async**
- Extensive **XML documentation**
- **No external dependencies** (uses integrated HTTP and JSON)
- **Custom exceptions** for advanced catching
- Execute **single** or **bulk** Replit GraphQL queries## Example
Under the `Example` directory you can find a working demo project that implements this library.## Code Samples
### Initializing a new GraphQL client with a valid session identifier cookie
```csharp
string sid = "s%3Bew5ttAQuBlAANjIh8ABSoTTtZ75-7AbH.ohRBI9wNPwOHED7GLltPBrOS975gxqATe1aL6y%9N3%2Fla";
ReplitGraphQLClient client = new(sid, "Example Application");
```### Executing a single query
```csharp
string userByUsername = @"
query userByUsername($username: String!) {
user: userByUsername(username: $username) {
id
bio
firstName
lastName
timeCreated
}
}";User user = (await client.Execute(userByUsername, new Dictionary()
{
{
"username", "akac"
}
}))?.User;
```### Executing bulk queries
```csharp
Repl[] repls = (await client.BulkExecute(new GraphQLParameters[]
{
new(replByUrl, new() { { "url", "https://replit.com/@amasad/TroubledPersonalBaitware" } }),
new(replByUrl, new() { { "url", "https://replit.com/@amasad/my-fun-new-app" } }),
new(replByUrl, new() { { "url", "https://replit.com/@amasad/comic-sans" } })
}))?.Select(data => data.Repl).ToArray();Console.WriteLine($"Retrieved {repls.Length} repls back");
foreach (Repl repl in repls) Console.WriteLine($"=> {repl.Title} ({repl.Id}) was created at {repl.TimeCreated}");
```## Available Methods
- Task\ **BulkExecuteRaw**(GraphQLParameters[] parameters, JsonSerializerOptions options = null)
- Task\ **ExecuteRaw**(string query, Dictionary variables = null, string operationName = null, JsonSerializerOptions options = null)
- Task\ **BulkExecute**(GraphQLParameters[] parameters, bool suppressErrors = false, JsonSerializerOptions options = null)
- Task\ **Execute**(string query, Dictionary variables = null, bool suppressErrors = false, string operationName = null, JsonSerializerOptions options = null)## References
- https://replit.com
- https://graphql.org