Quickstart
Setup
After installing the SDK, you need to import it. Here’s a simple example to get you started:
>>> import posit
Basic usage
Initialize a client
To get started, initialize a client to work with your Posit products. For this example, we will work with Posit Connect.
Keeping your API key secret is essential to protect your application’s security, prevent unauthorized access and usage, and ensure data privacy and regulatory compliance. By default, the API key is read from the CONNECT_API_KEY
environment variable when not provided by during client initialization.
>>> from posit import connect
>>> client = connect.Client(api_key="btOVKLXjt8CoGP2gXvSuTqu025MJV4da", url="https://connect.example.com")
Who am I?
Your API key is your secret identity. Now that we’re connected, let’s double check our username.
>>> client.me.username
'gandalf'
How much content do I have access to?
One of the best features of Connect is the ability to share content with your peers. Let’s see just how much content we have access to!
>>> client.content.count()
5754
Voilà! I have a whopping 5,754 pieces of content to browse.
Next steps
Check out the API Reference for more information.