Back to Home

Selected Fields

Learn how to use the selected fields feature to customize the data returned by the RUE API, optimizing your requests for efficiency and relevance.

Overview

The selected fields feature allows you to specify which data fields you want to receive in the API response. This can help reduce response size, improve performance, and focus on the most relevant data for your use case.

How to Use Selected Fields

To use selected fields, include the fields parameter in your API request. Here's an example using the scrape_metadata endpoint:

const axios = require('axios');

async function scrapeSelectedMetadata(url, fields) {
  try {
    const response = await axios.post('https://api.rue.ai/v1/scrape_metadata', 
      {
        url: url,
        fields: fields
      },
      {
        headers: {
          'Content-Type': 'application/json',
          'X-API-Key': 'YOUR_API_KEY'
        }
      }
    );
    console.log('Selected Metadata:', response.data);
  } catch (error) {
    console.error('Error:', error.response.data);
  }
}

// Example usage
const url = 'https://example.com';
const fields = ['title', 'description', 'og:image', 'author'];

scrapeSelectedMetadata(url, fields);

Available Fields

The available fields depend on the specific endpoint you're using. Here are some common fields for the scrape_metadata endpoint:

  • title
  • description
  • keywords
  • author
  • published_date
  • og:title
  • og:description
  • og:image
  • twitter:card
  • twitter:title
  • twitter:description
  • twitter:image

For a complete list of available fields for each endpoint, please refer to the API Reference.

Benefits of Using Selected Fields

  • Reduced response size and faster API calls
  • Lower bandwidth usage
  • Simplified data processing in your application
  • Ability to focus on specific data points relevant to your use case

Best Practices for Using Selected Fields

  • Only request the fields you actually need for your application
  • Group related fields together for more efficient processing
  • Consider caching frequently used field combinations
  • Use wildcard patterns (if supported) for selecting multiple related fields
  • Regularly review and update your selected fields as your application evolves

For more examples of how to use selected fields with different endpoints, check out our Examples page. If you have any questions about optimizing your API requests with selected fields, don't hesitate to reach out to our support team.