Skip to content

Commit

Permalink
Make the APIClient page Studio-centric
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Hellander committed Jul 6, 2024
1 parent 4194bd4 commit b3f6344
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
21 changes: 10 additions & 11 deletions docs/apiclient.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
APIClient
=========

.. note::

For access to FEDn Studio API, please see :ref:`studio-api`.

FEDn comes with an *APIClient* for interacting with the FEDn network. The APIClient is a Python3 library that can be used to interact with the FEDn network programmatically.
FEDn comes with an *APIClient* - a Python3 library that can be used to interact with FEDn programmatically.

**Installation**

Expand All @@ -17,12 +13,15 @@ The APIClient is available as a Python package on PyPI, and can be installed usi
**Initialize the APIClient**

To initialize the APIClient, you need to provide the hostname and port of the FEDn API server. The default port is 8092. The following code snippet shows how to initialize the APIClient:
The FEDn REST API is available at <controller-host>/api/v1/. To access this API you need the url to the controller-host, as well as an admin API token. The controller host can be found in the project dashboard (top right corner).
To obtain an admin API token, navigate to the "Settings" tab in your Studio project and click on the "Generate token" button. Copy the 'access' token and use it to access the API using the instructions below.


.. code-block:: python
from fedn import APIClient
client = APIClient("localhost", 8092)
>>> from fedn import APIClient
>>> client = APIClient(host="<controller-host>", token="<access-token>", secure=True, verify=True)
**Set active package and seed model**

Expand All @@ -38,9 +37,9 @@ To set the initial seed model, you can use the following code snippet:
client.set_active_model(path="path/to/seed.npz")
**Start training session**
**Start a training session**

Once the active package and seed model are set, you can connect clients to the network and start training models. The following code snippet initializes a session (training rounds):
Once the active package and seed model are set, you can connect clients to the network and start training models. The following code snippet starts a traing session:

.. code-block:: python
Expand Down
5 changes: 2 additions & 3 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ It is also possible to upload a package and seed model using the Python API Clie
Do this by going to the 'Settings' tab in FEDn Studio and click 'Generate token'. Copy the access token and use it in the APIClient below.
The controller host can be found on the main Dashboard in FEDn Studio.

You can also upload the file via the FEDn Studio UI. Please see :ref:`studio-upload-files` for more details.

Upload the package and seed model using the APIClient:
To upload the package and seed model using the APIClient:

.. code:: python
Expand Down Expand Up @@ -223,6 +221,7 @@ To start a client using Docker:
**Where to go from here?**
--------------------------

With you first FEDn federated project set up, we suggest that you take a close look at how a FEDn project is structured
and how you develop your own FEDn projects:
Expand Down

0 comments on commit b3f6344

Please sign in to comment.