A lightweight Unity client for Notion API. Fetch data from Notion databases and use it in your Unity projects.
- Database Queries: Query Notion databases with filters.
- Page Search: Find databases and pages by name at runtime.
- Image Download: Helper to download images from Notion URLs.
- Caching: Built-in memory cache for API responses.
- Property Helpers: Static methods to extract properties from JSON responses.
- Editor Tools: Fetch and browse databases/pages directly in Inspector.
- Open Window > Package Manager
- Click + > Add package from git URL...
- Enter
https://github.com/Seraf0-org/Unition.git
Add the following to your Packages/manifest.json:
{
"dependencies": {
"com.seraf.unition": "https://github.com/Seraf0-org/Unition.git"
}
}Create a config asset via Assets > Create > Unition > Notion Config and enter your Notion API key.
using Unition;
public class MyDataLoader : MonoBehaviour
{
public NotionConfig config;
async void Start()
{
var client = new NotionClient(config.apiKey, config.cacheDuration);
// Query by ID
string json = await client.QueryDatabase("your-database-id");
// Or find by name (v1.1.0+)
string dbId = await client.FindDatabaseIdByName("Cards");
string cardsJson = await client.QueryDatabase(dbId);
// Find pages by name
string pageId = await client.FindPageIdByName("Rules");
string pageJson = await client.GetPage(pageId);
}
}Use the NotionPropertyHelpers to extract data from Notion's JSON response:
using Unition;
// Extract various property types
string title = NotionPropertyHelpers.ExtractTitleProperty(pageJson, "Name");
string text = NotionPropertyHelpers.ExtractRichTextProperty(pageJson, "Description");
int number = NotionPropertyHelpers.ExtractNumberProperty(pageJson, "Count", defaultValue: 0);
string status = NotionPropertyHelpers.ExtractSelectProperty(pageJson, "Status");
List<string> tags = NotionPropertyHelpers.ExtractMultiSelectProperty(pageJson, "Tags");
List<string> relatedIds = NotionPropertyHelpers.ExtractRelationProperty(pageJson, "RelatedItems");
string imageUrl = NotionPropertyHelpers.ExtractImageUrl(pageJson, "Cover");Instead of hardcoding database IDs, you can define key-name mappings in the Inspector and resolve them at runtime.
Add mappings in your NotionConfig asset:
| Key | Database Name |
|---|---|
cards |
Cards |
items |
Items Database |
enemies |
Enemies |
using Unition;
public class GameDataManager : MonoBehaviour
{
public NotionConfig config;
async void Start()
{
var client = new NotionClient(config.apiKey, config.cacheDuration);
// Resolve all mappings
await config.ResolveAllAsync(client);
// Get resolved IDs by key
string cardsDbId = config.GetDatabaseId("cards");
string itemsDbId = config.GetDatabaseId("items");
// Query databases
string cardsJson = await client.QueryDatabase(cardsDbId);
}
}Click "Generate Keys Class" in the Inspector to create a constants file:
// Auto-generated: NotionDbKeys.cs
namespace Unition.Generated
{
public static class NotionDbKeys
{
public const string Cards = "cards";
public const string Items = "items";
}
}Now you get IDE autocomplete:
using Unition.Generated;
string cardsId = config.GetDatabaseId(NotionDbKeys.Cards); // ✓ Autocomplete!- Unity 2021.3 or later
- .NET Standard 2.1
- UniTask - For async/await support (recommended)
- Go to Notion Integrations
- Create a new integration
- Copy the "Internal Integration Token"
- Share your database with the integration
MIT License - see LICENSE for details.