Title: Import Data slow (API)
Last modified: April 13, 2019

---

# Import Data slow (API)

 *  Resolved [onetime1a](https://wordpress.org/support/users/onetime1a/)
 * (@onetime1a)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/import-data-slow-api/)
 * Hi,
 * I have an issue with slow loading times of the table because:
 * I get the values via shortcode from a google spreadsheet API and the more shortcodes
   I use, the slower the table load time. The page loads like >5 seconds longer 
   compared to pages with no table.
 * This is my plugin, where I get the data:
 * `<?php
 * /* Plugin Name: Custom Plugin for Code
    Description: Plugin for extra theme independent
   code */
 * function sheet_value_shortcode($atts) {
    $API = ‘mykey’; $google_spreadsheet_ID
   = ‘sheetID’; $api_key = esc_attr( $API);
 *  $location = $atts[‘location’];
 *  $get_cell = new WP_Http();
    $cell_url = “[https://sheets.googleapis.com/v4/spreadsheets/$google_spreadsheet_ID/values/$location?&key=$api_key&#8221](https://sheets.googleapis.com/v4/spreadsheets/$google_spreadsheet_ID/values/$location?&key=$api_key&#8221);;
   $cell_response = $get_cell -> get( $cell_url); $json_body = json_decode($cell_response[‘
   body’],true); $cell_value = $json_body[‘values’][0][0]; return $cell_value; }
   add_shortcode(‘get_sheet_value’, ‘sheet_value_shortcode’);
 * Is there any way how to improve this? for example just make 1 API call to get
   a range and then pull the data from there (via shortcode)?
    Thanks for any hint
   🙂
 * regards,
    lukas
    -  This topic was modified 7 years, 1 month ago by [onetime1a](https://wordpress.org/support/users/onetime1a/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fimport-data-slow-api%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/import-data-slow-api/#post-11423890)
 * Hi,
 * thanks for your question, and sorry for the trouble.
 * Yes, it might make more sense to make one query to the API and locally cache 
   it, e.g. in a WordPress transient in the database. Then, you could get the data
   from there.
 * Note that TablePress adds another layer of caching on top of the generated HTML(
   for not logged-in users).
 * Regards,
    Tobias
 *  Thread Starter [onetime1a](https://wordpress.org/support/users/onetime1a/)
 * (@onetime1a)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/import-data-slow-api/#post-11424825)
 * Thanks for info. I need to learn more about PHP and API implementation but I 
   enjoy this.
 * Sincerly,
    lukas
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/import-data-slow-api/#post-11424831)
 * Hi Lukas,
 * yes, it needs a bit of learning, but it indeed is great fun!
    And you can find
   many tutorials on Google and in the Developer Handbook at [https://developer.wordpress.org/plugins/](https://developer.wordpress.org/plugins/)
 * Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Import Data slow (API)’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/import-data-slow-api/#post-11424831)
 * Status: resolved