ThinNotionApi is an Elixir package to easily communicate with the Notion API. The main objective to provide a simple straight forward way for a person to fetch or update information without a large or complex interface.
If available in Hex, the package can be installed
by adding thin_notion_api
to your list of dependencies in mix.exs
:
def deps do
[
{:thin_notion_api, "~> 1.0.1"}
]
end
Next log in to the Notion Developers site. Visit My Integrations and create New Integration
. After creating your integration, you should now have a Internal Integration Token
you will use for all your Notion API requests. Make sure to keep this secret private and never leak it because at the moment you cannot regenerate a new one if compromised.
Add your integration token and which Version of the Notion API you are using (if not provided, it will default to 2021-08-16
) to config/config.exs:
config :thin_notion_api, :api_key, System.get_env("NOTION_API_KEY")
config :thin_notion_api, :notion_version, System.get_env("NOTION_VERSION")
You are good to go.
Retrieve information about a Notion database
iex> ThinNotionApi.Databases.retrieve_database(database_id)
{
:ok,
%{...}
}
Retrieves a Page object using the ID specified. Responses contains page properties, not page content. To fetch page content, use the retrieve block children endpoint.
iex> ThinNotionApi.Pages.retrieve_page(page_id)
{
:ok,
%{...}
}
Find all modules and functions you can use in the API Reference section.
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/thin_notion_api.
- List database
- Query database
- Page object actions
- Block actions
- User actions
- Search
TODO:
- Support changes for 2022-06-28
- Support changes for version 2022-02-22
Validate documentation by generating using following command
mix docs
You can spin up a quick web server to host documentation if you have node installed by using the following command:
npx http-serve doc
Ensure version in the mix.exs
has been properly incremented.
If everything looks good, you can release by running.
mix hex.publish