Skip to content

Commit cb04353

Browse files
authored
Merge pull request #63 from OpenSPP/refactor-structure-modify
Fix Headers on API Usage
2 parents 28587b9 + 9b11608 commit cb04353

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

docs/developer_guide/api_usage/dci_api.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ OpenSPP provides a RESTful API that adheres to the Digital Convergence Initiativ
1515
- Client credentials (Client ID and Client Secret) obtained from the OpenSPP instance.
1616
- Python 3.x and the `requests` library installed (`pip install requests`).
1717

18-
## 1. Authentication: Obtaining an Access Token
18+
## Process
19+
20+
### Authentication: Obtaining an Access Token
1921

2022
The DCI API is secured using OAuth 2.0 with the Client Credentials grant type. Before making any data requests, your application must obtain a bearer token.
2123

2224
- **Endpoint**: `/oauth2/client/token`
2325
- **Method**: `POST`
2426
- **Body**: `x-www-form-urlencoded` with `grant_type`, `client_id`, `client_secret`, `db_name`.
2527

26-
### Example: Get Access Token
28+
**Example: Get Access Token**
2729

2830
```python
2931
import requests
@@ -50,7 +52,7 @@ access_token = token_data.get("access_token")
5052
print("Access Token obtained successfully.")
5153
```
5254

53-
## 2. Searching the Registry
55+
### Searching the Registry
5456

5557
Once authenticated, you can use the access token to perform a synchronous search on the registry.
5658

@@ -61,7 +63,7 @@ Once authenticated, you can use the access token to perform a synchronous search
6163
- `Content-Type`: `application/json`
6264
- **Body**: A JSON object conforming to the DCI `sync/search` request specification.
6365

64-
### Example: Search for an Individual
66+
**Example: Search for an Individual**
6567

6668
```python
6769
search_url = f"{url}/registry/sync/search"
@@ -125,7 +127,7 @@ else:
125127
```
126128

127129

128-
## 3. Setup and Configuration
130+
### Setup and Configuration
129131

130132
To use the DCI API, you must first configure a client in OpenSPP.
131133

@@ -135,15 +137,14 @@ To use the DCI API, you must first configure a client in OpenSPP.
135137
4. **Reveal Credentials**: A **Show** button will appear. Click it to reveal the `Client ID` and `Client Secret`.
136138
5. **Important**: Copy these credentials immediately. For security, the **Show** button will disappear after you close the dialog, and you will not be able to retrieve the secret again.
137139

138-
## 4. Best Practices
140+
## Best Practices
139141

140142
1. **Secure Credential Storage**: Never hard-code your `Client ID` or `Client Secret` in your application. Use environment variables or a secure secret management system.
141143
2. **Token Management**: Access tokens are short-lived. Your application should handle token expiration and automatically request a new one when needed.
142144
3. **Error Handling**: Implement robust error handling to manage different HTTP status codes and error responses from the API.
143145
4. **Secure Connections**: Always use HTTPS for all API traffic to protect data in transit.
144146
5. **Logging**: Log request `transaction_id`s and correlation IDs to help with troubleshooting and auditing.
145147

146-
## 5. References
148+
## References
147149

148-
- [DCI Interface Standards v1.0](https://standards.spdci.org/standards/standards-for-interoperability-interfaces/structure-and-versioning-of-the-standards)
149-
- [Odoo 17 Developer Documentation](https://www.odoo.com/documentation/17.0/developer/)
150+
- [DCI Interface Standards v1.0](https://standards.spdci.org/standards/standards-for-interoperability-interfaces/structure-and-versioning-of-the-standards)

docs/developer_guide/api_usage/external_api_jsonrpc.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ This guide explains how to connect to and interact with OpenSPP Registry using t
1515
- User credentials or API key with appropriate permissions.
1616
- Python 3.x and the `requests` library installed (`pip install requests`).
1717

18-
## 1. Understanding JSON-RPC in OpenSPP
18+
## Process
19+
### Understanding JSON-RPC in OpenSPP
1920

2021
OpenSPP exposes much of its data and functionality via JSON-RPC endpoints. You can use these endpoints to authenticate, read, create, update, and delete records from external applications.
2122

2223
**Endpoint:**
2324
- `/jsonrpc` — All JSON-RPC calls (authentication and model methods)
2425

25-
## 1.1 JSON-RPC Payload Structure and Methods
26+
### JSON-RPC Payload Structure and Methods
2627

2728
All interactions with the OpenSPP JSON-RPC API use a standard payload structure. Each request is a JSON object with the following keys:
2829

@@ -59,11 +60,11 @@ payload = {
5960

6061
---
6162

62-
## 1.2 Common Model Methods and Args
63+
### Common Model Methods and Args
6364

6465
When using the `"object"` service with the `"execute_kw"` method, you can call various model methods. Here are the most common:
6566

66-
### `create`
67+
**`create`**
6768
Creates a new record.
6869

6970
**Args:**
@@ -79,7 +80,7 @@ Creates a new record.
7980
**Result:**
8081
Returns the ID of the newly created record.
8182

82-
### `write`
83+
**`write`**
8384
Updates existing records.
8485

8586
**Args:**
@@ -96,7 +97,7 @@ Updates existing records.
9697
**Result:**
9798
Returns a dictionary indicating the result of the update.
9899

99-
### `unlink`
100+
**`unlink`**
100101
Deletes records.
101102

102103
**Args:**
@@ -113,7 +114,7 @@ Deletes records.
113114
Returns a dictionary indicating the result of the deletion.
114115

115116

116-
### `search_read`
117+
**`search_read`**
117118
Searches for records and reads their fields.
118119

119120
**Args:**
@@ -141,7 +142,7 @@ Returns a dictionary of the search results.
141142

142143
---
143144

144-
## 2. Authentication
145+
### Authentication
145146

146147
You must authenticate before accessing most data. Use your password or an API key (recommended).
147148

@@ -170,9 +171,9 @@ if not uid:
170171
print("Authenticated UID:", uid)
171172
```
172173

173-
## 3. Working with Individuals
174+
### Working with Individuals
174175

175-
### Gather the Fields
176+
**Gather The Fields**
176177

177178
For this example we are going to use these fields:
178179

@@ -184,7 +185,7 @@ For this example we are going to use these fields:
184185
- `is_registrant` (boolean, default=True)
185186
- `is_group` (boolean, default=False)
186187

187-
### Example: Create an Individual
188+
**Example: Create an Individual**
188189

189190
```python
190191
# First, get a gender_id (e.g., for "Male")
@@ -254,9 +255,9 @@ updated = response["result"]
254255
print("Result:", updated)
255256
```
256257

257-
## 4. Working with Groups
258+
### Working with Groups
258259

259-
### Required Fields
260+
**Gather The Fields**
260261

261262
For this example we are going to use these fields:
262263

@@ -266,7 +267,7 @@ For this example we are going to use these fields:
266267
- `is_group` (boolean, default=True)
267268

268269

269-
### Example: Create a Group
270+
**Example: Create a Group**
270271

271272
```python
272273
# Get a group kind (e.g., "Household")
@@ -333,9 +334,9 @@ updated = response["result"]
333334
print("Result:", updated)
334335
```
335336

336-
## 5. Working with Memberships
337+
### Working with Memberships
337338

338-
### Required Fields
339+
**Gather The Fields**
339340

340341
From your `g2p_registry_membership` module, the main model is likely `g2p_registry_membership.group_membership`. Required fields typically include:
341342
- `individuak` (many2one, required)
@@ -344,7 +345,7 @@ From your `g2p_registry_membership` module, the main model is likely `g2p_regist
344345
- `start_date` (date, required)
345346
- Any other required fields as defined in your model
346347

347-
### Example: Add an Individual to a Group
348+
**Example: Add an Individual to a Group**
348349

349350
```python
350351
# Get a membership kind (e.g., "Head")
@@ -391,13 +392,13 @@ membership_id = response["result"]
391392
print("Created Membership ID:", membership_id)
392393
```
393394

394-
## 6. Security: Using API Keys
395+
### Security: Using API Keys
395396

396397
- **API keys** are recommended over passwords for scripts and integrations.
397398
- Generate API keys in your OpenSPP user preferences under **Account Security**.
398399
- Use the API key in place of your password in all JSON-RPC calls.
399400

400-
## 7. Best Practices
401+
## Best Practices
401402

402403
1. **Use API Keys**: Safer than passwords; revoke if compromised.
403404
2. **Limit Permissions**: Create dedicated users for API access with only necessary rights.
@@ -408,5 +409,4 @@ print("Created Membership ID:", membership_id)
408409
## References
409410

410411
- [Odoo 17 Developer Documentation](https://www.odoo.com/documentation/17.0/developer/)
411-
- [OpenSPP Developer Guide](https://docs.openspp.org/)
412412
- [JSON-RPC Specification](https://www.jsonrpc.org/specification)

0 commit comments

Comments
 (0)