@@ -50,44 +50,58 @@ Try accessing data.
50
50
Advanced Data Access with API Key
51
51
=================================
52
52
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.
55
60
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.
57
65
58
66
.. code-block :: python
59
67
60
68
import moabdb as mdb
61
69
62
70
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 )
64
72
print (test_df)
65
73
66
74
67
- Use Config File for API Key
68
- ---------------------------
75
+ Using `` config.ini `` File for Credentials
76
+ -----------------------------------------
69
77
70
78
Instead of hardcoding your email and API key in the code, a safer practice is to store them in a configuration file.
71
79
This method prevents the accidental exposure of sensitive credentials, especially if sharing or publishing your code.
72
80
73
- **Config File Setup **
81
+ **Create Config File **
74
82
75
83
Create a file named ``config.ini `` and structure it as follows:
76
84
77
- .. .. code-block:: python
78
- .. email = 'your-email@example.com'
79
- .. api_key = 'your-secret-api-key'
80
85
.. code-block :: ini
81
86
82
87
[Credentials]
83
88
email = ' your-email@example.com'
84
89
api_key = ' your-secret-api-key'
85
90
86
- **Using Credentials from the Config File in Python **
91
+ **Read Config File and Login **
87
92
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 **
91
105
92
106
.. code-block :: python
93
107
@@ -100,45 +114,17 @@ credentials from the config file and then login with your API key:
100
114
email = config[' Credentials' ][' email' ]
101
115
api_key = config[' Credentials' ][' api_key' ]
102
116
117
+ # Login and access data
103
118
mdb.login(email, api_key)
104
119
test_df = mdb.get_equity(' AAPL' , intraday = True )
105
120
print (test_df)
106
121
107
- Security Notes
108
- --------------
122
+ **Security Notes **
109
123
110
124
- Ensure your ``config.ini `` file is kept secure and out of the reach of unauthorized users.
111
125
- Never commit the ``config.ini `` file to public version control repositories to prevent exposure of your credentials.
112
126
113
127
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
-
142
128
Conclusion
143
129
----------
144
130
0 commit comments