Skip to content

Commit ecba338

Browse files
committed
example10
1 parent 5736dd9 commit ecba338

File tree

1 file changed

+30
-44
lines changed

1 file changed

+30
-44
lines changed

docs/source/tutorial/installation.rst

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -50,44 +50,58 @@ Try accessing data.
5050
Advanced Data Access with API Key
5151
=================================
5252

53-
Manually Enter Credentials
54-
--------------------------
53+
With an API key and subscription, intraday data is available.
54+
To access intraday data, you can enter your
55+
credentials by either:
56+
1. Manually entering your email and API
57+
2. Using a ``config.ini`` file
58+
59+
You then can use the ``mdb.login()`` function to login with your credentials.
5560

56-
With an API key and subscription, you can access additional data. To access the data you must first login with your API key.
61+
Manually Entering Credentials
62+
-----------------------------
63+
64+
To access advanced data you must first login with your API key.
5765

5866
.. code-block:: python
5967
6068
import moabdb as mdb
6169
6270
mdb.login('your-email', 'your-api-key')
63-
test_df = mdb.get_equity('AAPL',intraday=True)
71+
test_df = mdb.get_equity('AAPL', intraday=True)
6472
print(test_df)
6573
6674
67-
Use Config File for API Key
68-
---------------------------
75+
Using ``config.ini`` File for Credentials
76+
-----------------------------------------
6977

7078
Instead of hardcoding your email and API key in the code, a safer practice is to store them in a configuration file.
7179
This method prevents the accidental exposure of sensitive credentials, especially if sharing or publishing your code.
7280

73-
**Config File Setup**
81+
**Create Config File**
7482

7583
Create a file named ``config.ini`` and structure it as follows:
7684

77-
.. .. code-block:: python
78-
.. email = 'your-email@example.com'
79-
.. api_key = 'your-secret-api-key'
8085
.. code-block:: ini
8186
8287
[Credentials]
8388
email = 'your-email@example.com'
8489
api_key = 'your-secret-api-key'
8590
86-
**Using Credentials from the Config File in Python**
91+
**Read Config File and Login**
8792

88-
With an API key and subscription, intraday data is available.
89-
To access intraday data, you must first retrieve your
90-
credentials from the config file and then login with your API key:
93+
.. code-block:: python
94+
95+
import configparser
96+
import moabdb as mdb
97+
98+
# Read credentials from config file
99+
config = configparser.ConfigParser()
100+
config.read('config.ini')
101+
email = config['Credentials']['email']
102+
api_key = config['Credentials']['api_key']
103+
104+
**Login and Access Data**
91105

92106
.. code-block:: python
93107
@@ -100,45 +114,17 @@ credentials from the config file and then login with your API key:
100114
email = config['Credentials']['email']
101115
api_key = config['Credentials']['api_key']
102116
117+
# Login and access data
103118
mdb.login(email, api_key)
104119
test_df = mdb.get_equity('AAPL', intraday=True)
105120
print(test_df)
106121
107-
Security Notes
108-
--------------
122+
**Security Notes**
109123

110124
- Ensure your ``config.ini`` file is kept secure and out of the reach of unauthorized users.
111125
- Never commit the ``config.ini`` file to public version control repositories to prevent exposure of your credentials.
112126

113127

114-
115-
.. With an API key and subscription, intraday data is available. To access intraday data, you must first login with your API key:
116-
117-
.. .. code-block:: python
118-
119-
.. import moabdb as mdb
120-
121-
.. mdb.login('your-email', 'your-api-key')
122-
.. test_df = mdb.get_equity('AAPL',intraday=True)
123-
.. print(test_df)
124-
125-
126-
127-
128-
129-
130-
131-
132-
133-
.. Support and Further Reading
134-
.. ---------------------------
135-
136-
.. If you encounter any issues or need further assistance:
137-
138-
.. * Check out our `FAQ Section <link-to-faq>`_.
139-
.. * Dive deeper into our `API Reference <link-to-api-reference>`_.
140-
.. * For technical issues, contact our `support team <support-email>`_.
141-
142128
Conclusion
143129
----------
144130

0 commit comments

Comments
 (0)