|
34 | 34 | .embeddedOutputsTextElement.rightPaneElement,.embeddedOutputsVariableStringElement.rightPaneElement { min-height: 16px;} |
35 | 35 | .rightPaneElement .textElement { padding-top: 2px; padding-left: 9px;} |
36 | 36 | .S9 { margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; } |
37 | | -.S10 { border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 1px solid rgb(217, 217, 217); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; }</style></head><body><div class = rtcContent><h1 class = 'S0'><span>Getting Started with the MATLAB Central Interface for MATLAB</span></h1><h2 class = 'S1'><span>Description</span></h2><div class = 'S2'><span>The Community API allows developers to programmatically retrieve data from</span><span> </span><a href = "https://www.mathworks.com/matlabcentral"><span>MATLAB Central.</span></a><span> </span><span>The API offers a single resource to search across different MATLAB Central areas including MATLAB Answers, File Exchange, Blogs, Cody, Highlights and Contests. Use this toolbox for easy integration with the Community API from your MATLAB scripts and apps.</span></div><h2 class = 'S1'><span>System Requirements</span></h2><div class = 'S2'><span>Requires MATLAB® release R2017b or newer</span></div><h2 class = 'S1'><span>Functions</span></h2><ul class = 'S3'><li class = 'S4'><span style=' font-family: monospace;'>SearchApi.search </span><span>- Search MATLAB Central areas for content matching specified query. Areas you can search include MATLAB Answers, File Exchange, Blogs, Cody, Community Highlights, and Community Contests. The </span><span style=' font-style: italic;'>scope</span><span> parameter lets you restrict the request to specific MATLAB Central areas. The request accepts several other parameters to help narrow your search and create complex queries.</span></li></ul><h2 class = 'S1'><span>Usage</span></h2><div class = 'S2'><span>Download matlabcentral-matlab.mltbx</span><span> </span><span>into your workspace.</span></div><h2 class = 'S1'><span>Examples</span></h2><div class = 'S2'><span>The following example demonstrates calling the Search API to retrieve MATLAB Answers for content matching the query term 'plotting' in the last one year. The example also demonstrates the use of all optional query parameters supported by the API.</span></div><div class = 'S2'><span>Call the Search API using the </span><span style=' font-style: italic;'>search</span><span> method passing in values for all optional parameters</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S5'><span style="white-space: pre"><span >query = </span><span style="color: rgb(167, 9, 245);">"plotting"</span><span >;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >scope = </span><span style="color: rgb(167, 9, 245);">"file-exchange,matlab-answers"</span><span >;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >created_before = datetime(</span><span style="color: rgb(167, 9, 245);">'12-Mar-2023 11:00:00'</span><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >created_after = datetime(</span><span style="color: rgb(167, 9, 245);">'06-Mar-2022 11:00:00'</span><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >sort_order = </span><span style="color: rgb(167, 9, 245);">"created asc"</span><span >;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >page = 2;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >count = 15;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'> </div></div><div class="inlineWrapper outputs"><div class = 'S7'><span style="white-space: pre"><span >[searchResults, statusCode, headers] = SearchApi.search(query=query,scope=scope,created_before=created_before,created_after=created_after,sort_order=sort_order,page=page,count=count);</span></span></div><div class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsErrorElement" uid="1583FDAC" prevent-scroll="true" data-testid="output_0" style="width: 1145px; white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><div class="diagnosticMessage-wrapper diagnosticMessage-errorType eoOutputContent" data-previous-available-width="1115" data-previous-scroll-height="32" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: normal; font-style: normal; color: rgb(225, 27, 20); font-size: 12px;"><div class="diagnosticMessage-messagePart" style="white-space: pre-wrap; font-style: normal; color: rgb(225, 27, 20); font-size: 12px;">Error using SearchApi.search<br style="white-space: pre-wrap; font-style: normal; color: rgb(225, 27, 20); font-size: 12px;">HttpError:429 TooManyRequests</div><div class="diagnosticMessage-stackPart" style="white-space: pre; font-style: normal; color: rgb(225, 27, 20); font-size: 12px;"></div></div></div></div></div></div><div class = 'S9'><span>Extract the </span><span style=' font-style: italic;'>items</span><span> and </span><span style=' font-style: italic;'>total_found</span><span> objects from the response </span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S5'><span style="white-space: pre"><span >totalFound = searchResults.total_found;</span></span></div></div><div class="inlineWrapper"><div class = 'S10'><span style="white-space: pre"><span >items = searchResults.items</span></span></div></div></div><div class = 'S9'><span>Display the results as a table</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S5'><span style="white-space: pre"><span >disp(</span><span style="color: rgb(167, 9, 245);">"Response Status: " </span><span >+ statusCode);</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >disp(</span><span style="color: rgb(167, 9, 245);">"Found " </span><span >+ totalFound + </span><span style="color: rgb(167, 9, 245);">" total results"</span><span >)</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span style="color: rgb(14, 0, 255);">if </span><span >totalFound > 0</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span > </span><span style="color: rgb(14, 0, 255);">for </span><span >item = 1:length(items)</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span > disp(items(item))</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span > </span><span style="color: rgb(14, 0, 255);">end</span></span></div></div><div class="inlineWrapper"><div class = 'S10'><span style="white-space: pre"><span style="color: rgb(14, 0, 255);">end</span></span></div></div></div> |
| 37 | +.S10 { border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 1px solid rgb(217, 217, 217); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; }</style></head><body><div class = rtcContent><h1 class = 'S0'><span>Getting Started with the MATLAB Central Interface for MATLAB</span></h1><h2 class = 'S1'><span>Description</span></h2><div class = 'S2'><span>The Community API allows developers to programmatically retrieve data from</span><span> </span><a href = "https://www.mathworks.com/matlabcentral"><span>MATLAB Central.</span></a><span> </span><span>The API offers a single resource to search across different MATLAB Central areas including MATLAB Answers, File Exchange, Blogs, Cody, Highlights and Contests. Use this toolbox for easy integration with the Community API from your MATLAB scripts and apps.</span></div><h2 class = 'S1'><span>System Requirements</span></h2><div class = 'S2'><span>Requires MATLAB® release R2017b or newer</span></div><h2 class = 'S1'><span>Functions</span></h2><ul class = 'S3'><li class = 'S4'><span style=' font-family: monospace;'>SearchApi.search </span><span>- Search MATLAB Central areas for content matching specified query. Areas you can search include MATLAB Answers, File Exchange, Blogs, Cody, Community Highlights, and Community Contests. The </span><span style=' font-style: italic;'>scope</span><span> parameter lets you restrict the request to specific MATLAB Central areas. The request accepts several other parameters to help narrow your search and create complex queries.</span></li></ul><h2 class = 'S1'><span>Usage</span></h2><div class = 'S2'><span>Download MATLAB_Central_Interface_For_MATLAB.mltbx </span><span>into your workspace.</span></div><h2 class = 'S1'><span>Examples</span></h2><div class = 'S2'><span>The following example demonstrates calling the Search API to retrieve MATLAB Answers for content matching the query term 'plotting' in the last one year. The example also demonstrates the use of all optional query parameters supported by the API.</span></div><div class = 'S2'><span>Call the Search API using the </span><span style=' font-style: italic;'>search</span><span> method passing in values for all optional parameters</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S5'><span style="white-space: pre"><span >query = </span><span style="color: rgb(167, 9, 245);">"plotting"</span><span >;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >scope = </span><span style="color: rgb(167, 9, 245);">"file-exchange,matlab-answers"</span><span >;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >tags = </span><span style="color: rgb(167, 9, 245);">"legend"</span><span >;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >created_before = datetime(</span><span style="color: rgb(167, 9, 245);">'12-Mar-2023 11:00:00'</span><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >created_after = datetime(</span><span style="color: rgb(167, 9, 245);">'06-Mar-2022 11:00:00'</span><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >sort_order = </span><span style="color: rgb(167, 9, 245);">"created asc"</span><span >;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >page = 3;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >count = 15;</span></span></div></div><div class="inlineWrapper"><div class = 'S6'> </div></div><div class="inlineWrapper outputs"><div class = 'S7'><span style="white-space: pre"><span >[searchResults, statusCode, headers] = SearchApi.search(query=query,scope=scope,tags=tags,created_before=created_before,created_after=created_after,sort_order=sort_order,page=page,count=count);</span></span></div><div class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsErrorElement" uid="CC6F96D4" prevent-scroll="true" data-testid="output_0" style="width: 1145px; white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><div class="diagnosticMessage-wrapper diagnosticMessage-errorType eoOutputContent" data-previous-available-width="1115" data-previous-scroll-height="32" data-hashorizontaloverflow="false" style="max-height: 261px; white-space: normal; font-style: normal; color: rgb(225, 27, 20); font-size: 12px;"><div class="diagnosticMessage-messagePart" style="white-space: pre-wrap; font-style: normal; color: rgb(225, 27, 20); font-size: 12px;">Error using SearchApi.search<br style="white-space: pre-wrap; font-style: normal; color: rgb(225, 27, 20); font-size: 12px;">HttpError:429 TooManyRequests</div><div class="diagnosticMessage-stackPart" style="white-space: pre; font-style: normal; color: rgb(225, 27, 20); font-size: 12px;"></div></div></div></div></div></div><div class = 'S9'><span>Extract the </span><span style=' font-style: italic;'>items</span><span> and </span><span style=' font-style: italic;'>total_found</span><span> objects from the response </span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S5'><span style="white-space: pre"><span >totalFound = searchResults.total_found;</span></span></div></div><div class="inlineWrapper"><div class = 'S10'><span style="white-space: pre"><span >items = searchResults.items</span></span></div></div></div><div class = 'S9'><span>Display the results as a table</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S5'><span style="white-space: pre"><span >disp(</span><span style="color: rgb(167, 9, 245);">"Response Status: " </span><span >+ statusCode);</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >disp(</span><span style="color: rgb(167, 9, 245);">"Found " </span><span >+ totalFound + </span><span style="color: rgb(167, 9, 245);">" total results"</span><span >)</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span style="color: rgb(14, 0, 255);">if </span><span >totalFound > 0</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span > </span><span style="color: rgb(14, 0, 255);">for </span><span >item = 1:length(items)</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span > disp(items(item))</span></span></div></div><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span > </span><span style="color: rgb(14, 0, 255);">end</span></span></div></div><div class="inlineWrapper"><div class = 'S10'><span style="white-space: pre"><span style="color: rgb(14, 0, 255);">end</span></span></div></div></div> |
38 | 38 | <br> |
39 | 39 | <!-- |
40 | 40 | ##### SOURCE BEGIN ##### |
|
55 | 55 | % restrict the request to specific MATLAB Central areas. The request accepts several |
56 | 56 | % other parameters to help narrow your search and create complex queries. |
57 | 57 | %% Usage |
58 | | -% Download matlabcentral-matlab.mltbx into your workspace. |
| 58 | +% Download MATLAB_Central_Interface_For_MATLAB.mltbx into your workspace. |
59 | 59 | %% Examples |
60 | 60 | % The following example demonstrates calling the Search API to retrieve MATLAB |
61 | 61 | % Answers for content matching the query term 'plotting' in the last one year. |
|
67 | 67 |
|
68 | 68 | query = "plotting"; |
69 | 69 | scope = "file-exchange,matlab-answers"; |
| 70 | +tags = "legend"; |
70 | 71 | created_before = datetime('12-Mar-2023 11:00:00'); |
71 | 72 | created_after = datetime('06-Mar-2022 11:00:00'); |
72 | 73 | sort_order = "created asc"; |
73 | | -page = 2; |
| 74 | +page = 3; |
74 | 75 | count = 15; |
75 | 76 |
|
76 | | -[searchResults, statusCode, headers] = SearchApi.search(query=query,scope=scope,created_before=created_before,created_after=created_after,sort_order=sort_order,page=page,count=count); |
| 77 | +[searchResults, statusCode, headers] = SearchApi.search(query=query,scope=scope,tags=tags,created_before=created_before,created_after=created_after,sort_order=sort_order,page=page,count=count); |
77 | 78 | %% |
78 | 79 | % Extract the _items_ and _total_found_ objects from the response |
79 | 80 |
|
|
0 commit comments